gabriel / musehub public
fix patch issue-41-phase5 task/issue-41-phase5-keepalive-heartbeat #1 / 1
AI Agent gabriel · 117 days ago · May 10, 2026 · Diff

fix(issue-41-phase5): TCP keepalive + heartbeat frames in wire_push_stream

database.py: add tcp_keepalives_idle=30 to connect_args so the OS sends TCP keepalive probes every 30s, preventing asyncpg idle-connection reaping during MinIO I/O gaps on the streaming push path.

musehub_wire.py: emit a 'heartbeat' PROGRESS frame after each _flush_batch call when ≥10s have elapsed since the last heartbeat. Keeps the HTTP response stream alive through proxies during slow or large object batches. Module-level _monotonic alias (= time.monotonic) allows tests to patch it.

Tests (test_push_keepalive_heartbeat.py): - P5-1: mocked _monotonic advancing 11s/batch → ≥2 heartbeat P frames - P5-2: source check that init_db configures tcp_keepalives_idle

sha256:59205dc5364e3b8b8ee65784e60732f4779340533db3a9a0ab497996e27f3c23 sha
+40 ~2 symbols
sha256:b59c729dc2dbbcfa495a87b617bb91475376dd4a0c2cd25edf7af226862c17e3 snapshot
+40
symbols added
~2
symbols modified
0
dead code introduced
Semantic Changes 42 symbols
+ OBATCH variable variable OBATCH L54–54
+ _collect function async_function _collect L134–138
+ _commit_pack function function _commit_pack L84–90
+ _end function function _end L93–94
+ _fw variable variable _fw L53–53
+ _header function function _header L69–74
+ _make_repo function async_function _make_repo L97–114
+ _object_frame function function _object_frame L77–81
+ _pack function function _pack L61–62
+ _stub_backend function function _stub_backend L117–131
+ _wrap function function _wrap L65–66
+ Any import import Any L32–32
+ AsyncIterator import import AsyncIterator L30–30
+ AsyncMock import import AsyncMock L33–33
+ AsyncSession import import AsyncSession L37–37
+ JSONObject import import JSONObject L51–51
+ JSONValue import import JSONValue L51–51
+ MuseWireFrameWriter import import MuseWireFrameWriter L40–40
+ SFRAME_COMMIT_PACK import import SFRAME_COMMIT_PACK L42–42
+ SFRAME_END import import SFRAME_END L42–42
+ SFRAME_HEADER import import SFRAME_HEADER L42–42
+ SFRAME_OBJECT import import SFRAME_OBJECT L42–42
+ SFRAME_PROGRESS import import SFRAME_PROGRESS L42–42
+ SFRAME_RESULT import import SFRAME_RESULT L42–42
+ STREAM_OBJECT_BATCH_SIZE import import STREAM_OBJECT_BATCH_SIZE L42–42
+ annotations import import annotations L25–25
+ blob_id import import blob_id L39–39
+ datetime import import datetime L31–31
+ db import import db L41–41
+ inspect import import inspect L27–27
+ math import import math L28–28
+ msgpack import import msgpack L35–35
+ now_utc_iso import import now_utc_iso L39–39
+ pytest import import pytest L36–36
+ secrets import import secrets L29–29
+ timezone import import timezone L31–31
+ test_p5_1_heartbeat_frames_emitted_during_slow_upload function async_function test_p5_1_heartbeat_frames_emitted_during_slow_upload L146–225
+ test_p5_2_keepalive_configured_on_pool function function test_p5_2_keepalive_configured_on_pool L232–249
~ musehub/db/database.py .py 1 symbol modified
~ musehub/services/musehub_wire.py .py 2 symbols added, 1 symbol modified
+ _monotonic variable variable _monotonic L83–83
+ _time_module import import _time_module L27–27
← Older Oldest on task/issue-41-phase5-keepalive-heartbeat
All commits
Newer → Latest on task/issue-41-phase5-keepalive-heartbeat

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:59205dc5364e3b8b8ee65784e60732f4779340533db3a9a0ab497996e27f3c23 --body "your comment"