Repository navigation
test(sentinel): cover +switch-master during rediscovery after a server-side close - #2293
Merged
PavelPashov merged 1 commit intoNov 16, 2026
Conversation
…r-side close The failover detector of a closed connection must not abort the next master lookup. Cleaning it up when its stream closes (redis#2198) covers this, but the existing tests only close the stream through QUIT. Co-Authored-By: Claude Opus 5.5 <[email protected]>
mplanitzer
marked this pull request as ready for review
November 16, 2026 12:30
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
🎉 This PR is included in version 6.1.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
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.
#2198 cleans up a connection's failover detector when its stream closes. Its tests close the stream through QUIT. This PR adds a test for a server-side close. 6.0.0 has this bug, and the same cleanup fixes it:
failoverDetector: true, the server closes the client's connection, for example through a demoted master'sCLIENT KILLor a network drop.SentinelConnector.disconnect()does not run.get-master-addr-by-name).+switch-masterone after another, so one announcement can reach the old detector during that lookup. In 6.0.0 the old detector is still subscribed. It callsconnector.disconnect(), which setsconnecting = false, and thenconnectToNextthrowsConnection is closed.. The client stays inendpermanently, and every later command fails withConnection is closed..On main, the stream-close cleanup from #2198 stops the old detector at step 1, so the client reaches
ready.Changes
test/functional/sentinel.ts: the master mock destroys the client's socket. The Sentinel mock then publishes+switch-masterto the open subscriptions while it answersget-master-addr-by-name. The test runs with RESP 2 and RESP 3.SentinelConnector: the comment on the streamclosecleanup now also names server-side closes, so that a later change doesn't limit the cleanup to QUIT.Tests
expected 'end' to equal 'ready', RESP 2 and 3). It also fails on main when thefailoverDetector.cleanup()call is removed from the streamclosehandler. It passes on main and passed 15 repeated runs.test/functional/sentinel.tsandtest/unit/connectors/SentinelConnector: 66 passing (Node 24.22.3, macOS).Not run: the full suite against a real Redis, and the cluster tests.
6.0.0 is still the latest stable release. Until 6.1.0 ships, 6.0.x users can only avoid this with a custom
Connectorthat cleans up the previous detector inconnect().🤖 Generated with Claude Code
Note
Low Risk
No runtime behavior changes—comment clarification and regression tests only.
Overview
Adds RESP 2 and RESP 3 functional coverage for a Sentinel failover race that previously left the client stuck on
endinstead of reconnecting toready.The new test simulates a server-side master disconnect (socket destroy, not
QUIT), then delivers+switch-masterto existing failover subscriptions whileget-master-addr-by-nameis still in flight. It asserts the client recovers toready, guarding the streamclosebehavior that cleans up the oldFailoverDetector.SentinelConnectoronly updates the comment on thatclosehandler to spell out that QUIT and server-side closes both need the same cleanup, so a stale detector cannot calldisconnect()mid-reconnect.Reviewed by Cursor Bugbot for commit 4f6cf05. Bugbot is set up for automated code reviews on this repo. Configure here.