[Tarantool-patches] [PATCH 3/6] raft: new candidate should wait for leader death
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Wed Oct 14 02:28:29 MSK 2020
When a raft node was configured to be a candidate via
election_mode, it didn't do anything if there was an active
leader.
But it should have started monitoring its health in order to
initiate a new election round when it dies.
The patch fixes this bug. It does not contain a test, because will
be covered by a test for #5339.
Needed for #5339
---
src/box/raft.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/box/raft.c b/src/box/raft.c
index f51e87fde..ff28e7f08 100644
--- a/src/box/raft.c
+++ b/src/box/raft.c
@@ -926,12 +926,18 @@ raft_cfg_is_candidate(bool is_candidate)
if (raft.is_candidate) {
assert(raft.state == RAFT_STATE_FOLLOWER);
- /*
- * If there is an on-going WAL write, it means there was some
- * node who sent newer data to this node.
- */
- if (raft.leader == 0 && raft_is_fully_on_disk())
+ if (raft.leader != 0) {
+ raft_sm_wait_leader_dead();
+ } else if (raft_is_fully_on_disk()) {
raft_sm_wait_leader_found();
+ } else {
+ /*
+ * If there is an on-going WAL write, it means there was
+ * some node who sent newer data to this node. So it is
+ * probably a better candidate. Anyway can't do anything
+ * until the new state is fully persisted.
+ */
+ }
} else if (raft.state != RAFT_STATE_FOLLOWER) {
if (raft.state == RAFT_STATE_LEADER)
raft.leader = 0;
--
2.21.1 (Apple Git-122.3)
More information about the Tarantool-patches
mailing list