Skip to content
Snippets Groups Projects
Commit 20f78220 authored by Georgy Moshkin's avatar Georgy Moshkin :speech_balloon: Committed by Georgy Moshkin
Browse files

fix: wasn't emitting raft.demoted when not in joint state

parent ddc0ef5b
No related branches found
No related tags found
1 merge request!219Resolve "Graceful shutdown times out quite often"
...@@ -563,7 +563,17 @@ fn handle_committed_conf_change(entry: traft::Entry, raw_node: &mut RawNode) { ...@@ -563,7 +563,17 @@ fn handle_committed_conf_change(entry: traft::Entry, raw_node: &mut RawNode) {
let raft_id = &raw_node.raft.id; let raft_id = &raw_node.raft.id;
let voters_old = Storage::voters().unwrap(); let voters_old = Storage::voters().unwrap();
if voters_old.contains(raft_id) && !conf_state.voters.contains(raft_id) { if voters_old.contains(raft_id) && !conf_state.voters.contains(raft_id) {
event::broadcast_when(Event::Demoted, Event::LeaveJointState).ok(); #[rustfmt::skip]
let is_joint_state = with_joint_state_latch(|latch| {
// joint_state_latch is stored in `Cell` so to check it's value
// we must take it out and put it back in
latch.take().map(|l| { latch.set(Some(l)); true }).unwrap_or(false)
});
if is_joint_state {
event::broadcast_when(Event::Demoted, Event::LeaveJointState).ok();
} else {
event::broadcast(Event::Demoted);
}
} }
Storage::persist_conf_state(&conf_state).unwrap(); Storage::persist_conf_state(&conf_state).unwrap();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment