gabriel / musehub public
fix patch issue-41-phase2 task/issue-41-phase2-separate-finalization-session #1 / 1
AI Agent gabriel · 117 days ago · May 10, 2026 · Diff

fix(issue-41-phase2): separate finalization session in wire_push_stream

After the frame loop completes, close the object-storage session to release its connection back to the pool, then acquire a fresh session via AsyncSessionLocal() for all finalization writes (snapshot upserts, commit INSERTs, branch update). This prevents asyncpg idle-connection reaping from killing the connection between MinIO object writes and the DB finalization phase.

Tests: - test_push_session_phase2.py: 3 new tests (P2B-1 close called, P2B-2 source uses AsyncSessionLocal, P2B-3 push survives dead original session) - test_push_per_batch_commit_phase2.py: updated P2-1 through P2-4 to intercept fin_session via _async_session_factory wrapper instead of db_session directly - test_push_per_batch_commit.py: updated P1-1/P1-2/P1-3 commit count assertions to reflect that finalization commits now go to fin_session, deleted obsolete P1-6

sha256:64894c3f121dac80b0069dc12142074caa05a2707c4a7ff6154432052908b48b sha
+44 ~8 −1 symbols
sha256:dad6b5ddcfed3d63db9ab4c9689bde77ceb43a4051da6f060fc424f206767361 snapshot
+44
symbols added
~8
symbols modified
−1
symbol removed
0
dead code introduced
Semantic Changes 53 symbols
~ tests/test_push_session_phase2.py .py 44 symbols added
+ CBATCH variable variable CBATCH L60–60
+ _collect function async_function _collect L141–145
+ _commit_pack function function _commit_pack L90–95
+ _end function function _end L98–99
+ _frames_of_type function function _frames_of_type L148–149
+ _fw variable variable _fw L59–59
+ _header function function _header L75–80
+ _make_chain function function _make_chain L128–138
+ _make_commit function function _make_commit L102–117
+ _make_repo function async_function _make_repo L152–168
+ _make_snapshot function function _make_snapshot L120–125
+ _object_frame function function _object_frame L83–87
+ _pack function function _pack L67–68
+ _push function async_function _push L189–205
+ _stub_backend function function _stub_backend L171–186
+ _wrap function function _wrap L71–72
+ Any import import Any L38–38
+ AsyncIterator import import AsyncIterator L36–36
+ AsyncSession import import AsyncSession L43–43
+ JSONObject import import JSONObject L57–57
+ JSONValue import import JSONValue L57–57
+ MuseWireFrameWriter import import MuseWireFrameWriter L46–46
+ SFRAME_COMMIT_PACK import import SFRAME_COMMIT_PACK L48–48
+ SFRAME_END import import SFRAME_END L48–48
+ SFRAME_ERROR import import SFRAME_ERROR L48–48
+ SFRAME_HEADER import import SFRAME_HEADER L48–48
+ SFRAME_OBJECT import import SFRAME_OBJECT L48–48
+ SFRAME_RESULT import import SFRAME_RESULT L48–48
+ STREAM_COMMIT_BATCH_SIZE import import STREAM_COMMIT_BATCH_SIZE L48–48
+ annotations import import annotations L31–31
+ blob_id import import blob_id L45–45
+ datetime import import datetime L37–37
+ db import import db L47–47
+ inspect import import inspect L33–33
+ math import import math L34–34
+ msgpack import import msgpack L40–40
+ now_utc_iso import import now_utc_iso L45–45
+ pytest import import pytest L41–41
+ secrets import import secrets L35–35
+ select import import select L42–42
+ timezone import import timezone L37–37
+ test_p2b_1_session_close_called_after_frame_loop function async_function test_p2b_1_session_close_called_after_frame_loop L213–251
+ test_p2b_2_source_uses_async_session_local_for_finalization function function test_p2b_2_source_uses_async_session_local_for_finalization L259–275
+ test_p2b_3_push_survives_dead_original_session function async_function test_p2b_3_push_survives_dead_original_session L283–352
~ tests/test_push_per_batch_commit.py .py 1 symbol removed, 3 symbols modified
← Older Oldest on task/issue-41-phase2-separate-finalization-session
All commits
Newer → Latest on task/issue-41-phase2-separate-finalization-session

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:64894c3f121dac80b0069dc12142074caa05a2707c4a7ff6154432052908b48b --body "your comment"