fix: improve reconnect recovery with async lock fix and immediate redo trigger#323
Open
cxhello wants to merge 2 commits into
Open
fix: improve reconnect recovery with async lock fix and immediate redo trigger#323cxhello wants to merge 2 commits into
cxhello wants to merge 2 commits into
Conversation
…tHandler The handler used synchronous 'with' on an asyncio.Lock, which does not actually acquire the lock. Change to 'async with' to properly guard the status check and server switch when handling ConnectResetRequest. Signed-off-by: cxhello <caixiaohuichn@gmail.com>
…p to 30s After gRPC reconnection, on_connected() only set self._connected = True. The redo task polled _execute_redo_channel with a 30-second timeout, so instance re-registration could be delayed up to 30 seconds. Now on_connected() also calls start_redo_task() to signal the channel immediately, waking the redo task to re-register instances without delay. Signed-off-by: cxhello <caixiaohuichn@gmail.com>
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.
What type of PR is this?
What does this PR do?
Two small fixes to improve reconnect recovery after gRPC connection drops:
Fix async lock bug in
ConnectResetRequestHandler: The handler used synchronouswithon anasyncio.Lock, which does not actually acquire the lock (asyncio.Lock.__enter__is a no-op withoutawait acquire()). Changed toasync withto properly guard the status check and server switch when handlingConnectResetRequestfrom the server.Trigger redo immediately on reconnect: After gRPC reconnection,
on_connected()only setself._connected = True. The redo task polled_execute_redo_channelwith a 30-second timeout, so instance re-registration could be delayed up to 30 seconds. Nowon_connected()also calls the existingstart_redo_task()method to signal the channel immediately, waking the redo task to re-register instances without delay.Which issue(s) does this PR fix?
Related to alibaba/nacos#14106
How has this been tested?
start_redo_task()→_execute_redo_channel.put(None)→_execute_redo_taskwakes up → checks_connected(already True) → callsredo_task()to re-register instancesrpc_client.pyChecklist