Skip to content

Commit

Permalink
Another update to Election algorithm
Browse files Browse the repository at this point in the history
If a node reboots while it's election is in `Running` state and during
the interval, the election is `Finished`. The rebooted node was not able
to join the finished election. If the election is `Finished` for the
same term.

If we receive a rumor that says election is not `Finished` while our
state of the election is `Finished` and we steal their vote and make a
`hot` rumor so that the other member gets a chance to `finish` their
election.

Signed-off-by: Abhijit Gadgil <[email protected]>
  • Loading branch information
agadgil-progress committed Oct 7, 2024
1 parent 5b6418e commit f11fa06
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions components/butterfly/src/rumor/election.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,19 @@ impl Rumor for Election {
*self = other;
true
} else if other.term == self.term && self.status == ElectionStatus::Finished {
debug!("stored rumor is finished and received rumor is for same term; nothing to do");
false
if other.status == ElectionStatus::Finished {
debug!("stored rumor is finished and received rumor is for same term; nothing to \
do");
false
} else {
debug!("stored rumor is finished and received rumor is for same term; Received \
rumor is not 'Finished'. Taking their votes and sharing ourselves.");
self.steal_votes(&mut other);
true
}
} else if self.term > other.term {
debug!("stored rumor represents a newer term than received; keep sharing it");
true
} else if self.term > other.term {
debug!("stored rumor represents a newer term than received; keep sharing it");
true
Expand Down

0 comments on commit f11fa06

Please sign in to comment.