Repository navigation
Do election in order based on failed primary rank to avoid voting conflicts - #1018
Merged
Merged
Conversation
…flicts When multiple primary nodes fail simultaneously, the cluster can not recover within the default effective time (data_age limit). The main reason is that the vote is without ranking among multiple replica nodes, which case too many epoch conflicts. Therefore, we introduced into ranking based on the failed primary node name. Introduced a new failed_primary_rank var, this var means the rank of this myself instance in the context of all failed primary list. This var will be used in failover and we will do the failover election packets in order based on the rank, this can effectively avoid the voting conflicts. Signed-off-by: Binbin <[email protected]>
enjoy-binbin
commented
Sep 11, 2024
Signed-off-by: Binbin <[email protected]>
Signed-off-by: Binbin <[email protected]>
Signed-off-by: Binbin <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #1018 +/- ##
============================================
+ Coverage 70.83% 70.85% +0.01%
============================================
Files 120 120
Lines 64911 64937 +26
============================================
+ Hits 45982 46012 +30
+ Misses 18929 18925 -4
|
PingXie
reviewed
Sep 23, 2024
PingXie
left a comment
Member
There was a problem hiding this comment.
LGTM overall. I like this idea. Thanks @enjoy-binbin!
Signed-off-by: Binbin <[email protected]>
Signed-off-by: Binbin <[email protected]>
Member
|
Seems like a good idea to me as well. |
Signed-off-by: Binbin <[email protected]>
Signed-off-by: Binbin <[email protected]>
madolson
reviewed
Jan 10, 2025
madolson
approved these changes
Jan 10, 2025
madolson
left a comment
Member
There was a problem hiding this comment.
Directionally good with this change, the remaining tests still look good.
Signed-off-by: Binbin <[email protected]>
proost
pushed a commit
to proost/valkey
that referenced
this pull request
Jan 17, 2025
…flicts (valkey-io#1018) When multiple primary nodes fail simultaneously, the cluster can not recover within the default effective time (data_age limit). The main reason is that the vote is without ranking among multiple replica nodes, which case too many epoch conflicts. Therefore, we introduced into ranking based on the failed primary shard-id. Introduced a new failed_primary_rank var, this var means the rank of this myself instance in the context of all failed primary list. This var will be used in failover and we will do the failover election packets in order based on the rank, this can effectively avoid the voting conflicts. If a single primary is down, the behavior is the same as before. If multiple primaries are down, their replica election initiation time will be delayed by 500ms according to the ranking. Signed-off-by: Binbin <[email protected]> Signed-off-by: proost <[email protected]>
kronwerk
pushed a commit
to kronwerk/valkey
that referenced
this pull request
Jan 27, 2025
…flicts (valkey-io#1018) When multiple primary nodes fail simultaneously, the cluster can not recover within the default effective time (data_age limit). The main reason is that the vote is without ranking among multiple replica nodes, which case too many epoch conflicts. Therefore, we introduced into ranking based on the failed primary shard-id. Introduced a new failed_primary_rank var, this var means the rank of this myself instance in the context of all failed primary list. This var will be used in failover and we will do the failover election packets in order based on the rank, this can effectively avoid the voting conflicts. If a single primary is down, the behavior is the same as before. If multiple primaries are down, their replica election initiation time will be delayed by 500ms according to the ranking. Signed-off-by: Binbin <[email protected]>
enjoy-binbin
added a commit
to enjoy-binbin/valkey
that referenced
this pull request
Jun 17, 2025
This rank was added in valkey-io#1018, we should reset it to zero when doing the manual failover, just like we reset failover auth rank. It affects subsequent log printing. When there is a manual failover and there are multiple primaries failure, `Start of election` will print a confusing log. Signed-off-by: Binbin <[email protected]>
enjoy-binbin
added a commit
that referenced
this pull request
Jun 18, 2025
This rank was added in #1018, we should reset it to zero when doing the manual failover, just like we reset failover auth rank. It affects subsequent log printing. When there is a manual failover and there are multiple primaries failure, `Start of election` will print a confusing log. Signed-off-by: Binbin <[email protected]>
ranshid
pushed a commit
to ranshid/valkey
that referenced
this pull request
Jun 18, 2025
…ey-io#2226) This rank was added in valkey-io#1018, we should reset it to zero when doing the manual failover, just like we reset failover auth rank. It affects subsequent log printing. When there is a manual failover and there are multiple primaries failure, `Start of election` will print a confusing log. Signed-off-by: Binbin <[email protected]>
ranshid
pushed a commit
to ranshid/valkey
that referenced
this pull request
Sep 30, 2025
…ey-io#2226) This rank was added in valkey-io#1018, we should reset it to zero when doing the manual failover, just like we reset failover auth rank. It affects subsequent log printing. When there is a manual failover and there are multiple primaries failure, `Start of election` will print a confusing log. Signed-off-by: Binbin <[email protected]>
zuiderkwast
pushed a commit
that referenced
this pull request
Oct 1, 2025
This rank was added in #1018, we should reset it to zero when doing the manual failover, just like we reset failover auth rank. It affects subsequent log printing. When there is a manual failover and there are multiple primaries failure, `Start of election` will print a confusing log. Signed-off-by: Binbin <[email protected]>
sarthakaggarwal97
pushed a commit
to sarthakaggarwal97/valkey
that referenced
this pull request
Apr 27, 2026
…flicts (valkey-io#1018) When multiple primary nodes fail simultaneously, the cluster can not recover within the default effective time (data_age limit). The main reason is that the vote is without ranking among multiple replica nodes, which case too many epoch conflicts. Therefore, we introduced into ranking based on the failed primary shard-id. Introduced a new failed_primary_rank var, this var means the rank of this myself instance in the context of all failed primary list. This var will be used in failover and we will do the failover election packets in order based on the rank, this can effectively avoid the voting conflicts. If a single primary is down, the behavior is the same as before. If multiple primaries are down, their replica election initiation time will be delayed by 500ms according to the ranking. Signed-off-by: Binbin <[email protected]> (cherry picked from commit 211b250)
sarthakaggarwal97
pushed a commit
to sarthakaggarwal97/valkey
that referenced
this pull request
Apr 27, 2026
…flicts (valkey-io#1018) When multiple primary nodes fail simultaneously, the cluster can not recover within the default effective time (data_age limit). The main reason is that the vote is without ranking among multiple replica nodes, which case too many epoch conflicts. Therefore, we introduced into ranking based on the failed primary shard-id. Introduced a new failed_primary_rank var, this var means the rank of this myself instance in the context of all failed primary list. This var will be used in failover and we will do the failover election packets in order based on the rank, this can effectively avoid the voting conflicts. If a single primary is down, the behavior is the same as before. If multiple primaries are down, their replica election initiation time will be delayed by 500ms according to the ranking. Signed-off-by: Binbin <[email protected]> (cherry picked from commit 211b250) (cherry picked from commit bbbbead)
valkeyrie-ops Bot
added a commit
that referenced
this pull request
Dec 2, 2026
The test rejects a split vote, which this branch's server can only resolve by letting the election expire. In the log replica 9 won epoch 8 at 09:10:11.797, then replicas 7 and 8 both started an election for epoch 9 at 09:10:12.143 and 09:10:12.145. Primaries 3 and 6 and the new primary 9 voted for replica 7, primaries 4 and 5 voted for replica 8, so the votes were 3 to 2 with a needed quorum of 4 and no one won the epoch. Because no node claimed an epoch equal to or higher than 9, neither election was reset, and both replicas logged "Failover attempt expired" from 09:10:42. On 8.0 the retry comes after four times the node timeout, 60 s with cluster-node-timeout 15000, while the test waits 50 s and failed at 09:10:46. The election delay on 8.0 is a fixed 500 + random() % 500 ms with no ranking across failed shards, so the larger node timeout ported earlier does not space the shards' elections here and only makes the retry slower. A split vote in which no candidate reaches the majority, followed by a timeout and a retry, is correct server behaviour on 8.0, so the test should accept it rather than the server changing. The exception is narrow: a replica may time out only if it started an election in an epoch in which another replica also started one and which no replica won, as read from the "Starting a failover election for epoch" and "configEpoch set to N after successful failover" log lines. A replica that times out although another node won its epoch, which is what the test exists to catch, still fails. I kept the natural timing of the three elections instead of releasing the replicas one by one, because serialising them would stop the test from ever exercising same-epoch elections or the false epoch 0 case. No product change is made: upstream avoids or resolves split votes with features (failed primary ranking in #1018, the FAILOVER_AUTH_NACK message in #3833) that are not minimal backports for this branch. CI-Fix-Job: test-ubuntu-latest CI-Fix-Run: https://github.com/valkey-io/valkey/actions/runs/46245707417 Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
valkeyrie-ops Bot
added a commit
that referenced
this pull request
Dec 3, 2026
The test rejects a split vote, which this branch's server can only resolve by letting the election expire. In the log replica 9 won epoch 8 at 09:10:11.797, then replicas 7 and 8 both started an election for epoch 9 at 09:10:12.143 and 09:10:12.145. Primaries 3 and 6 and the new primary 9 voted for replica 7, primaries 4 and 5 voted for replica 8, so the votes were 3 to 2 with a needed quorum of 4 and no one won the epoch. Because no node claimed an epoch equal to or higher than 9, neither election was reset, and both replicas logged "Failover attempt expired" from 09:10:42. On 8.0 the retry comes after four times the node timeout, 60 s with cluster-node-timeout 15000, while the test waits 50 s and failed at 09:10:46. The election delay on 8.0 is a fixed 500 + random() % 500 ms with no ranking across failed shards, so the larger node timeout ported earlier does not space the shards' elections here and only makes the retry slower. A split vote in which no candidate reaches the majority, followed by a timeout and a retry, is correct server behaviour on 8.0, so the test should accept it rather than the server changing. The exception is narrow: a replica may time out only if it started an election in an epoch in which another replica also started one and which no replica won, as read from the "Starting a failover election for epoch" and "configEpoch set to N after successful failover" log lines. A replica that times out although another node won its epoch, which is what the test exists to catch, still fails. I kept the natural timing of the three elections instead of releasing the replicas one by one, because serialising them would stop the test from ever exercising same-epoch elections or the false epoch 0 case. No product change is made: upstream avoids or resolves split votes with features (failed primary ranking in #1018, the FAILOVER_AUTH_NACK message in #3833) that are not minimal backports for this branch. CI-Fix-Job: test-ubuntu-latest CI-Fix-Run: https://github.com/valkey-io/valkey/actions/runs/46245707417 Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.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.
When multiple primary nodes fail simultaneously, the cluster can not recover
within the default effective time (data_age limit). The main reason is that
the vote is without ranking among multiple replica nodes, which case too many
epoch conflicts.
Therefore, we introduced into ranking based on the failed primary shard-id.
Introduced a new failed_primary_rank var, this var means the rank of this
myself instance in the context of all failed primary list. This var will be
used in failover and we will do the failover election packets in order based
on the rank, this can effectively avoid the voting conflicts.
If a single primary is down, the behavior is the same as before. If multiple
primaries are down, their replica election initiation time will be delayed
by 500ms according to the ranking.