test(client): fix flaky cluster PubSub listener-move test - #3347
Merged
nkaradzhov merged 1 commit intoJul 21, 2026
Merged
nkaradzhov merged 1 commit into
nkaradzhov merged 1 commit into
Conversation
The 'should move listeners when PubSub node disconnects from the cluster' test reassigned all 8192 slots with CLUSTER SETSLOT ... NODE, interleaving the commands to the migrating and importing nodes. That leaves the nodes in a transient cluster_state:fail window, so any command sent while the nodes converge fails with 'CLUSTERDOWN The cluster is down'. Claim the slots on the importing node first, then release them on the migrating node, and wait for both nodes to report cluster_state:ok before triggering the MOVED redirect. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
PavelPashov
approved these changes
Jul 21, 2026
Comment on lines
+407
to
+414
| const importingPromises: Array<Promise<unknown>> = [], | ||
| migratingPromises: Array<Promise<unknown>> = []; | ||
| for (let i = range.start; i <= range.end; i++) { | ||
| promises.push( | ||
| migratingClient.clusterSetSlot(i, 'NODE', importing.id), | ||
| importingClient.clusterSetSlot(i, 'NODE', importing.id) | ||
| ); | ||
| importingPromises.push(importingClient.clusterSetSlot(i, 'NODE', importing.id)); | ||
| migratingPromises.push(migratingClient.clusterSetSlot(i, 'NODE', importing.id)); | ||
| } | ||
| await Promise.all(importingPromises); | ||
| await Promise.all(migratingPromises); |
Contributor
There was a problem hiding this comment.
Could we create the migrating promises only after the importing batch completes? Calling both methods while building the arrays queues both batches immediately, so the current awaits do not enforce the intended ordering.
Suggested change
| const importingPromises: Array<Promise<unknown>> = [], | |
| migratingPromises: Array<Promise<unknown>> = []; | |
| for (let i = range.start; i <= range.end; i++) { | |
| promises.push( | |
| migratingClient.clusterSetSlot(i, 'NODE', importing.id), | |
| importingClient.clusterSetSlot(i, 'NODE', importing.id) | |
| ); | |
| importingPromises.push(importingClient.clusterSetSlot(i, 'NODE', importing.id)); | |
| migratingPromises.push(migratingClient.clusterSetSlot(i, 'NODE', importing.id)); | |
| } | |
| await Promise.all(importingPromises); | |
| await Promise.all(migratingPromises); | |
| const importingPromises: Array<Promise<unknown>> = []; | |
| for (let i = range.start; i <= range.end; i++) { | |
| importingPromises.push(importingClient.clusterSetSlot(i, 'NODE', importing.id)); | |
| } | |
| await Promise.all(importingPromises); | |
| const migratingPromises: Array<Promise<unknown>> = []; | |
| for (let i = range.start; i <= range.end; i++) { | |
| migratingPromises.push(migratingClient.clusterSetSlot(i, 'NODE', importing.id)); | |
| } | |
| await Promise.all(migratingPromises); |
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.
Description
Fixes a flaky test:
Cluster > PubSub > should move listeners when PubSub node disconnects from the clusterintermittently fails in CI with:The test reassigns all 8192 slots of the PubSub node with
CLUSTER SETSLOT <slot> NODE <id>, interleaving the commands to the migrating and the importing node. While the two nodes converge on the new slot ownership, they can pass through a transientcluster_state:failwindow, and any command served during that window fails withCLUSTERDOWN The cluster is down. The test itself already carried aTODO: is there a better way to migrate slots without causing CLUSTERDOWN?comment.This pull request resolves the flakiness by:
cluster_state:okviaCLUSTER INFObefore triggering theMOVEDredirect.Test-only change; no runtime behavior is affected. The test passed 10/10 consecutive runs with this change.
🤖 Generated with Claude Code
Note
Low Risk
Test-only change to slot-migration setup in one spec; no runtime or library behavior is affected.
Overview
Fixes intermittent
CLUSTERDOWN The cluster is downfailures in the cluster PubSub test that simulates a node leaving the cluster by reassigning thousands of slots.The test no longer interleaves
CLUSTER SETSLOT … NODEon the migrating and importing masters. It claims slots on the importing node first, then releases them on the migrating node, and pollsCLUSTER INFOuntil both nodes reportcluster_state:okbefore issuing theGETthat triggersMOVEDand the publish/assert path.Test-only change; no production client behavior is modified.
Reviewed by Cursor Bugbot for commit a69b8bb. Bugbot is set up for automated code reviews on this repo. Configure here.