Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the election was reset wrongly before failover epoch was obtained #1339

Open
wants to merge 1 commit into
base: unstable
Choose a base branch
from

Conversation

enjoy-binbin
Copy link
Member

After #1009, we will reset the election when we received
a claim with an equal or higher epoch since a node can win
an election in the past.

But we need to consider the time before the node actually
obtains the failover_auth_epoch. The failover_auth_epoch
default is 0, so before the node actually get the failover
epoch, we might wrongly reset the election.

This is probably harmless, but will produce misleading log
output and may delay election by a cron cycle or beforesleep.
Now we will only reset the election when a node is actually
obtains the failover epoch.

After valkey-io#1009, we will reset the election when we received
a claim with an equal or higher epoch since a node can win
an election in the past.

But we need to consider the time before the node actually
obtains the failover_auth_epoch. The failover_auth_epoch
default is 0, so before the node actually get the failover
epoch, we might wrongly reset the election.

This is probably harmless, but will produce misleading log
output and may delay election by a cron cycle or beforesleep.
Now we will only reset the election when a node is actually
obtains the failover epoch.

Signed-off-by: Binbin <binloveplay1314@qq.com>
Copy link

codecov bot commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.61%. Comparing base (50aae13) to head (c2d5d61).
Report is 4 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #1339      +/-   ##
============================================
- Coverage     70.76%   70.61%   -0.16%     
============================================
  Files           116      116              
  Lines         63271    63281      +10     
============================================
- Hits          44776    44688      -88     
- Misses        18495    18593      +98     
Files with missing lines Coverage Δ
src/cluster_legacy.c 86.30% <100.00%> (-0.22%) ⬇️

... and 14 files with indirect coverage changes

---- 🚨 Try these New Features:

Comment on lines -3150 to 3154
if (server.cluster->failover_auth_time && sender->configEpoch >= server.cluster->failover_auth_epoch) {
if (server.cluster->failover_auth_time && server.cluster->failover_auth_sent &&
sender->configEpoch >= server.cluster->failover_auth_epoch) {
/* Another node has claimed an epoch greater than or equal to ours.
* If we have an ongoing election, reset it because we cannot win
* with an epoch smaller than or equal to the incoming claim. This
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this comment even says "If we have an ongoing election, reset it", so it's good to check that we actually have an ongoing election (failover_auth_sent). Very clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants