Repository navigation
fix(cluster): return ErrClosing instead of MOVED/ASK after Close - #1037
Open
ninadsutrave wants to merge 1 commit into
Open
ninadsutrave wants to merge 1 commit into
ninadsutrave wants to merge 1 commit into
Conversation
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.
When
Close()has been called,shouldRefreshRetrystops following redirections, so a call that gets aMOVEDorASKreply at that point returns the raw redirection error to the caller. TheClosedocs say pending calls should seeErrClosing, so following @rueian's suggestion in #937 this returnsErrClosingforDo,DoMulti,DoCacheandDoMultiCache.The
stopcheck inshouldRefreshRetryitself is unchanged, since removing it would keep retrying against closed connections. Dedicated clients andReceiveare left as they are because they don't follow redirections anyway.Added
TestClusterClientRedirectWhileClosing, which closes the client from inside the mock before replying withMOVED/ASK. It fails on main and passes with this change.This only covers the
Close()path, not the DNS timeout case reported later in the issue.Related to #937
Note
Low Risk
Targeted error-mapping on shutdown with tests; redirect/retry logic is otherwise unchanged.
Overview
After
Close(), in-flight cluster commands that receive MOVED or ASK now surfaceErrClosinginstead of the raw redirect error, matching documented behavior for pending work during shutdown.A new
isClosingRedirecthelper detects redirect replies when the client’sstopflag is set.Do,DoCache, and the multi/cache result handlers apply it at the end of redirect/retry handling (without changingshouldRefreshRetry, so closed clients still do not follow redirects).TestClusterClientRedirectWhileClosingcloses the client from a mock and assertsErrClosingforDo,DoMulti,DoCache, andDoMultiCachewith both MOVED and ASK.Reviewed by Cursor Bugbot for commit 4578d0b. Bugbot is set up for automated code reviews on this repo. Configure here.