Skip to content

Commit

Permalink
include leader_id or current role info in vote log (#546)
Browse files Browse the repository at this point in the history
Signed-off-by: glorv <glorvs@163.com>
  • Loading branch information
glorv committed May 14, 2024
1 parent 25b6676 commit 1ccd1f3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/raft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1147,12 +1147,14 @@ impl<T: Storage> Raft<T> {
let pending_request_snapshot = self.pending_request_snapshot;
self.reset(term);
self.leader_id = leader_id;
let from_role = self.state;
self.state = StateRole::Follower;
self.pending_request_snapshot = pending_request_snapshot;
info!(
self.logger,
"became follower at term {term}",
term = self.term;
"from_role" => ?from_role,
);
}

Expand Down Expand Up @@ -1365,6 +1367,7 @@ impl<T: Storage> Raft<T> {
"term" => self.term,
"remaining ticks" => self.election_timeout - self.election_elapsed,
"msg type" => ?m.get_msg_type(),
"leader_id" => self.leader_id,
);

return Ok(());
Expand Down

0 comments on commit 1ccd1f3

Please sign in to comment.