Repository navigation
fix: wait for in-flight acquisitions when closing connection pools - #8244
Open
maximilliangrand wants to merge 1 commit into
Open
maximilliangrand wants to merge 1 commit into
maximilliangrand wants to merge 1 commit into
Conversation
|
|
maximilliangrand
force-pushed
the
fix/connection-pool-close-handshake
branch
from
October 29, 2026 15:57
1e51830 to
18029e9
Compare
This branch has not been deployed
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.
ConnectionPool.aclose()can return while an ordinaryget()is still opening a connection. The close invalidates the in-flight attempt, so_connect()closes that result and retries after shutdown has already returned, leaving the replacement connection open. An acquisition draining a retired connection has the same race.Serialize invalidation and draining in
aclose()with the existing connection lock. This waits for the acquisition to finish before closing its connection. Prewarm cancellation still happens before taking the lock, and the pool can still be reused after closing.The regressions cover blocked handshakes and blocked drains, exact-once closure, reuse, and cancellation of an in-flight prewarm. Both acquisition cases fail before the fix; all 19 pool tests pass with it. A separate loopback TCP reproduction leaves one live socket before the fix and none afterward.
Validation:
049aea8,uv run --no-sync pytest tests/test_connection_pool.py --unit -q: 19 passed.make checkpassed: Ruff formatting/lint and mypy across all 737 source files. Local commands used the checkout's core/plugin roots inPYTHONPATHto work around an editable-install import issue on macOS.The full local unit/audio-EOT suite was not repeated after rebasing. The earlier Python 3.14 run passed 6,096 tests but encountered twelve NumPy buffer-resize failures and nine missing-
livekit-serversetup errors, reproduced on the unchanged base, plus one audio-decoder cancellation failure that passed in isolation on both trees. Fresh PR CI will validate the updated head.No live provider credentials were used. Implementation and independent review were AI-assisted.