You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`Vote` is a similar concept to paxos proposer-id.
It is defined by a tuple of `(term, uncommitted|committed, node_id)`.
A Candidate creates an uncommitted `Vote` to identify it, as a
replacement of `(term, candidate_id)`.
A Leader has a `Vote` that is committed, i.e., the vote is granted by a
quorum.
The rule for overriding a `Vote` is defined by a **partially ordered**
relation: a node is only allowed to grant a greater vote.
The partial order relation covers all behavior of the `vote` in raft
spec. This way wee make the test very easy to be done.
With `Vote`, checking validity of a request is quite simple: just by
`self.vote <= rpc.vote`.
- Rename: save_hard_state() and read_hard_state() to save_vote() and read_vote().
- Replace `term, node_id` pair with `Vote` in RaftCore and RPC struct-s.
- Fix: request handler for append-entries and install-snapshot should
save the vote they received.
self.set_target_state(State::Follower);// State update will emit metrics.
77
55
}
78
56
79
-
self.current_leader = Some(msg.leader_id);
80
-
81
-
if report_metrics {
82
-
self.report_metrics(Update::AsIs);
83
-
}
57
+
self.report_metrics(Update::AsIs);
84
58
}
85
59
86
-
// Transition to follower state if needed.
87
-
if !self.target_state.is_follower() && !self.target_state.is_learner(){
88
-
self.set_target_state(State::Follower);
89
-
}
60
+
// Caveat: [commit-index must not advance the last known consistent log](https://datafuselabs.github.io/openraft/replication.html#caveat-commit-index-must-not-advance-the-last-known-consistent-log)
61
+
62
+
// TODO(xp): cleanup commit index at sender side.
63
+
let valid_commit_index = msg_entries.last().map(|x| Some(x.log_id)).unwrap_or_else(|| req.prev_log_id);
64
+
let valid_committed = std::cmp::min(req.leader_commit, valid_commit_index);
0 commit comments