fix(sync): resolve sporadic deadlocks during rapid db teardown#431
Open
borjamoskv wants to merge 1 commit into
Open
fix(sync): resolve sporadic deadlocks during rapid db teardown#431borjamoskv wants to merge 1 commit into
borjamoskv wants to merge 1 commit into
Conversation
Fixes #413 - Wrap asyncio.gather() in asyncio.wait_for() with 5s timeout - On TimeoutError, log warning and force loop.close() to avoid indefinite hang when tasks hold SovereignLock during teardown - return_exceptions=True ensures atomic collection of CancelledError from all tasks before proceeding to shutdown_asyncgens/executor - Homeostasis preserved: existing close() path unchanged
Contributor
∞ MÖBIUS — PR Analysis
Labels applied: Warning No test files detected in this PR. Consider adding tests. Generated by MÖBIUS (Clojure/Babashka) — where code IS data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #413
asyncio.gather()inasyncio.wait_for()with 5s timeoutTimeoutError, log warning and forceloop.close()to avoid indefinite hang when tasks holdSovereignLockduring teardownreturn_exceptions=Trueensures atomic collection ofCancelledErrorfrom all tasks before proceeding toshutdown_asyncgens/executorclose()path unchanged🧠 CORTEX-PERSIST PULL REQUEST
■ EPISTEMIC HUMILITY CHECKLIST
All generative AI code is treated as conjecture until deterministic validation is proven. You MUST check all boxes before this PR can be merged.
persistencedo not break existing SHA-256 Merkle chain validation.■ ARCHITECTURAL IMPACT
Context:
SyncMixin.close_sync()runs task cancellation vialoop.run_until_complete(asyncio.gather(*tasks))with no timeout. When tasks holdSovereignLockreferences during rapid teardown sequences (e.g., test suite 2228-gate), the gather blocks indefinitely causing sporadic CI timeout errors.Changes: Added
asyncio.wait_for(..., timeout=5.0)wrapper around the gather. OnTimeoutError, aWARNINGis logged and teardown proceeds forcefully — residual blocking calls inteardown()are abandoned. This unblocks the event loop and allowsloop.close()to complete.Telemetry / Performance Delta: No performance regression. Timeout path only triggers on pathological shutdown sequences. Steady-state close latency unchanged.
■ VERIFICATION EVIDENCE