valkey-io / valkey

A flexible distributed key-value datastore that is optimized for caching and other realtime workloads.
https://valkey.io
Other
17.36k stars 656 forks source link

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

Open enjoy-binbin opened 18 hours ago

enjoy-binbin commented 18 hours ago

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.

codecov[bot] commented 17 hours ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

Additional details and impacted files ```diff @@ 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](https://app.codecov.io/gh/valkey-io/valkey/pull/1339?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=valkey-io) | Coverage Δ | | |---|---|---| | [src/cluster\_legacy.c](https://app.codecov.io/gh/valkey-io/valkey/pull/1339?src=pr&el=tree&filepath=src%2Fcluster_legacy.c&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=valkey-io#diff-c3JjL2NsdXN0ZXJfbGVnYWN5LmM=) | `86.30% <100.00%> (-0.22%)` | :arrow_down: | ... and [14 files with indirect coverage changes](https://app.codecov.io/gh/valkey-io/valkey/pull/1339/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=valkey-io)

🚨 Try these New Features: