Fix term updates in Memgraph HA
Summary: Fix https://app.asana.com/0/870082256568329/1117622284146426/f Reviewers: mferencevic, ipaljak Reviewed By: mferencevic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1949
This commit is contained in:
parent
67ff1cdce3
commit
97e2289222
@ -146,6 +146,14 @@ void RaftServer::Start() {
|
||||
election_change_.notify_all();
|
||||
});
|
||||
|
||||
// [Raft paper figure 2]
|
||||
// If RPC request or response contains term T > currentTerm,
|
||||
// set currentTerm = T and convert to follower.
|
||||
if (req.term > current_term_) {
|
||||
SetCurrentTerm(req.term);
|
||||
if (mode_ != Mode::FOLLOWER) Transition(Mode::FOLLOWER);
|
||||
}
|
||||
|
||||
// [Raft paper 5.3]
|
||||
// "If a follower's log is inconsistent with the leader's, the
|
||||
// consistency check will fail in the AppendEntries RPC."
|
||||
@ -180,14 +188,6 @@ void RaftServer::Start() {
|
||||
}
|
||||
}
|
||||
|
||||
// [Raft paper figure 2]
|
||||
// If RPC request or response contains term T > currentTerm,
|
||||
// set currentTerm = T and convert to follower.
|
||||
if (req.term > current_term_) {
|
||||
SetCurrentTerm(req.term);
|
||||
if (mode_ != Mode::FOLLOWER) Transition(Mode::FOLLOWER);
|
||||
}
|
||||
|
||||
AppendLogEntries(req.leader_commit, req.prev_log_index + 1, req.entries);
|
||||
|
||||
// [Raft paper 5.3]
|
||||
|
Loading…
Reference in New Issue
Block a user