Commit 9bfd517
committed
Improve: tolerate leader state reversion upon restart
When a leader restarted and its log reverted, and tried to re-elect
itself as leader:
And when vote request is rejected and see a greater vote,
it should only update to the non-committed version of the responded vote
to its local state:
This prevents a dangerous scenario when state reversion is allowed:
1. A node was a leader but its state reverted to a previous version;
2. The node restarts and begins election;
3. It receives a vote response containing its own previous leader vote;
4. Without this protection, it would update to that committed vote and
become leader again;
5. However, it lacks the necessary logs, causing committed entries to be
lost or inconsistent;
By using the non-committed version, we prevent this reverted node from
becoming leader while still allowing proper vote updates for legitimate
cases.1 parent 49a7df1 commit 9bfd517
2 files changed
+15
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
661 | 661 | | |
662 | 662 | | |
663 | 663 | | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | | - | |
674 | | - | |
675 | | - | |
676 | | - | |
677 | | - | |
678 | | - | |
679 | | - | |
680 | | - | |
681 | 664 | | |
682 | 665 | | |
683 | 666 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
389 | 403 | | |
390 | | - | |
| 404 | + | |
391 | 405 | | |
392 | 406 | | |
393 | 407 | | |
| |||
0 commit comments