[Tarantool-patches] [PATCH v4 09/12] raft: introduce raft_start/stop_candidate
Serge Petrenko
sergepetrenko at tarantool.org
Mon Apr 19 15:52:40 MSK 2021
16.04.2021 19:25, Serge Petrenko пишет:
> Extract raft_start_candidate and raft_stop_candidate functions from
> raft_cfg_is_candidate.
>
> These functions will be used in manual elections.
>
> Prerequisite #3055
>
Follow-up fixes:
=============================
diff --git a/src/lib/raft/raft.c b/src/lib/raft/raft.c
index 3f900db9a..46a30149f 100644
--- a/src/lib/raft/raft.c
+++ b/src/lib/raft/raft.c
@@ -886,7 +886,11 @@ raft_start_candidate(struct raft *raft)
void
raft_stop_candidate(struct raft *raft, bool do_demote)
{
- if (!raft->is_candidate)
+ /*
+ * May still be the leader after raft_stop_candidate
+ * with do_demote = false.
+ */
+ if (!raft->is_candidate && raft->state != RAFT_STATE_LEADER)
return;
raft->is_candidate = false;
if (raft->state != RAFT_STATE_LEADER) {
--
Serge Petrenko
More information about the Tarantool-patches
mailing list