Skip to content

Commit

Permalink
Fix: a stepped down leader should ignore replication progress message
Browse files Browse the repository at this point in the history
  • Loading branch information
drmingdrmer committed Feb 12, 2023
1 parent 2bbaaff commit a80579e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions openraft/src/core/raft_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1354,12 +1354,15 @@ impl<C: RaftTypeConfig, N: RaftNetworkFactory<C>, S: RaftStorage<C>> RaftCore<C,
tracing::warn!("leader has removed target: {}", target);
};
} else {
unreachable!("no longer a leader, received message from previous leader");
// TODO: A leader may have stepped down.
}
}

self.engine.replication_handler().update_progress(target, id, result);
self.run_engine_commands::<Entry<C>>(&[]).await?;
// TODO: A leader may have stepped down.
if self.engine.internal_server_state.is_leading() {
self.engine.replication_handler().update_progress(target, id, result);
self.run_engine_commands::<Entry<C>>(&[]).await?;
}

Ok(())
}
Expand Down

0 comments on commit a80579e

Please sign in to comment.