fix: prevent "Cannot invoke RPC on closed channel" after connection recovery#3326
Open
XuanYang-cn wants to merge 3 commits intomilvus-io:masterfrom
Open
fix: prevent "Cannot invoke RPC on closed channel" after connection recovery#3326XuanYang-cn wants to merge 3 commits intomilvus-io:masterfrom
XuanYang-cn wants to merge 3 commits intomilvus-io:masterfrom
Conversation
…ecovery ConnectionManager._recover() previously created a new handler object and stored it in managed.handler, but MilvusClient._handler and in-flight retry loops still referenced the old (closed) handler. Any subsequent RPC on the stale reference raised "Cannot invoke RPC on closed channel". Fix: add reconnect() to GrpcHandler/AsyncGrpcHandler that resets the gRPC channel in-place (close + re-setup on the same object). _recover() now calls handler.reconnect() instead of creating a new handler, so all existing references remain valid. Additional changes: - Add recovery_gen counter to ManagedConnection for concurrent recovery guard (replaces handler identity check that no longer applies) - Add get_recovery_address() to strategies so GlobalStrategy can pass the new primary endpoint to reconnect() - Add concurrency unit tests proving the lock + gen guard prevent double reconnect under thread contention Signed-off-by: xuan.yang <xuan.yang@zilliz.com>
- Fix stale docstring in AsyncConnectionManager._register_error_callback that described old handler-replacement mechanism; updated to describe in-place reconnect and recovery_gen guard - Remove no-op recovery_gen guard from async handle_error (asyncio lock is held throughout, so gen can never change between read and check) - Add warning log in GlobalStrategy.get_recovery_address when topology is unavailable, so silent fallback to current address is observable - Add test for the topology-unavailable warning scenario Signed-off-by: xuan.yang <xuan.yang@zilliz.com>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: XuanYang-cn The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3326 +/- ##
==========================================
+ Coverage 90.04% 90.06% +0.01%
==========================================
Files 64 64
Lines 13638 13656 +18
==========================================
+ Hits 12281 12299 +18
Misses 1357 1357 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…rage Add TestHandlerReconnect class exercising the real GrpcHandler.reconnect() and AsyncGrpcHandler.reconnect() implementations with parametrized tests covering address handling, close-failure recovery, and timeout forwarding. Signed-off-by: xuan.yang <xuan.yang@zilliz.com>
1a24eb2 to
0c1a07c
Compare
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.
Summary
ConnectionManager._recover()— a regression from the ConnectionManager introduced in 2.6.10 (feat: add ConnectionManager to replace connections singleton for MilvusClient #3283)_recover()previously created a new handler object, butMilvusClient._handlerand in-flight retry loops still referenced the old (closed) handlerreconnect()toGrpcHandler/AsyncGrpcHandlerthat resets the gRPC channel in-place (same object, new channel), so all references remain validrecovery_gencounter toManagedConnectionfor concurrent recovery guardget_recovery_address()to strategies soGlobalStrategypasses new primary endpoint🤖 Generated with Claude Code