Skip to content

Commit

Permalink
fix: add a limit when leader tries to shtuduwn a node that has been s…
Browse files Browse the repository at this point in the history
…hutdown

Signed-off-by: themanforfree <[email protected]>
  • Loading branch information
themanforfree authored and Phoenix500526 committed Dec 1, 2023
1 parent 3e12563 commit 844fc53
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions curp/src/server/curp_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ impl<C: 'static + Command, RC: RoleChange + 'static> CurpNode<C, RC> {
let connect_id = connect.id();
let batch_timeout = curp.cfg().batch_timeout;
let mut is_shutdown_state = false;
let mut ae_fail_count = 0;

#[allow(clippy::integer_arithmetic)] // tokio select internal triggered
let leader_retired = loop {
Expand Down Expand Up @@ -736,6 +737,13 @@ impl<C: 'static + Command, RC: RoleChange + 'static> CurpNode<C, RC> {
if matches!(err, SendAEError::NotLeader) {
break true;
}
if is_shutdown_state {
ae_fail_count += 1;
if ae_fail_count >= 5 {
warn!("the follower {} may have been shutdown", connect_id);
break false;
}
}
} else {
hb_opt = true;
}
Expand Down

0 comments on commit 844fc53

Please sign in to comment.