Fix flake replicas different ranks test#3164
Merged
enjoy-binbin merged 7 commits intovalkey-io:unstablefrom Feb 5, 2026
Merged
Fix flake replicas different ranks test#3164enjoy-binbin merged 7 commits intovalkey-io:unstablefrom
enjoy-binbin merged 7 commits intovalkey-io:unstablefrom
Conversation
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
enjoy-binbin
approved these changes
Feb 5, 2026
Member
|
I'm thinking we might be able to avoid this problem within the cluster code, R6 shouldn't actually be able to initiate an election with a new epoch. The one of the purpose of the test is to ensure that the replica with rank 0 can win. Let me think about it some more. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## unstable #3164 +/- ##
============================================
+ Coverage 74.87% 74.97% +0.09%
============================================
Files 129 129
Lines 71309 71318 +9
============================================
+ Hits 53393 53468 +75
+ Misses 17916 17850 -66 🚀 New features to boost your workflow:
|
Member
|
emm, look like we can't (or unable to find out in a short time). I am merging it, it is a good fix, thank you. |
Contributor
|
Thanks @hanxizh9910! |
sarthakaggarwal97
pushed a commit
to sarthakaggarwal97/valkey
that referenced
this pull request
Feb 6, 2026
Address valkey-io#2683 For the test, I found two problems. ### 1. Test Assumes Winner Has Rank #0 In my test run, in the failing case: - Replica -3 (rank 0) won epoch 10 first - Replica -6 (rank 1) won epoch 11 second - Replica -3 saw higher epoch and stepped down - Final result: rank 1 became master Rank #0 doesn't guarantee being the final master. ### 2. Pattern Matching Bug The pattern `*Start of election*rank #0*` incorrectly matches "primary rank #0": Log: `Start of election delayed for 350 milliseconds (rank #1, primary rank #0, offset 2172)` This line has rank `#1`, but the pattern matches because of "primary rank `#0`" at the end. ## Solution - Fixed the format problem by checking if `(rank #0` or `(rank #1` so that we won't accidentally match the primary rank - Only check to make sure replica 3 and replica 6 have different ranks without assuming the replica with rank 0 will become the master. Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
harrylin98
pushed a commit
to harrylin98/valkey_forked
that referenced
this pull request
Feb 19, 2026
Address valkey-io#2683 For the test, I found two problems. ### 1. Test Assumes Winner Has Rank #0 In my test run, in the failing case: - Replica -3 (rank 0) won epoch 10 first - Replica -6 (rank 1) won epoch 11 second - Replica -3 saw higher epoch and stepped down - Final result: rank 1 became master Rank #0 doesn't guarantee being the final master. ### 2. Pattern Matching Bug The pattern `*Start of election*rank #0*` incorrectly matches "primary rank #0": Log: `Start of election delayed for 350 milliseconds (rank #1, primary rank #0, offset 2172)` This line has rank `#1`, but the pattern matches because of "primary rank `#0`" at the end. ## Solution - Fixed the format problem by checking if `(rank #0` or `(rank #1` so that we won't accidentally match the primary rank - Only check to make sure replica 3 and replica 6 have different ranks without assuming the replica with rank 0 will become the master. Signed-off-by: Hanxi Zhang <hanxizh@amazon.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.
Closes #2683
For the test, I found two problems.
1. Test Assumes Winner Has Rank #0
In my test run, in the failing case:
Rank #0 doesn't guarantee being the final master.
2. Pattern Matching Bug
The pattern
*Start of election*rank #0*incorrectly matches "primary rank #0":Log:
Start of election delayed for 350 milliseconds (rank #1, primary rank #0, offset 2172)This line has rank
#1, but the pattern matches because of "primary rank#0" at the end.This is the test example. I added some print statements in the test
Solution
(rank #0or(rank #1so that we won't accidentally match the primary rankTest
I ran it for 1000 times: https://github.com/hanxizh9910/valkey/actions/runs/21705632232