From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@dev.tarantool.org, sergepetrenko@tarantool.org
Subject: [Tarantool-patches] [PATCH 3/6] raft: new candidate should wait for leader death
Date: Wed, 14 Oct 2020 01:28:29 +0200 [thread overview]
Message-ID: <325b6fd1b87444f6cefdacf80e28cd9f692adb29.1602631481.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1602631481.git.v.shpilevoy@tarantool.org>
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)
next prev parent reply other threads:[~2020-10-13 23:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-13 23:28 [Tarantool-patches] [PATCH 0/6] Raft auto-commit Vladislav Shpilevoy
2020-10-13 23:28 ` [Tarantool-patches] [PATCH 1/6] test: add '_stress' suffix to election_qsync test Vladislav Shpilevoy
2020-10-13 23:28 ` [Tarantool-patches] [PATCH 2/6] raft: factor out the code to wakeup worker fiber Vladislav Shpilevoy
2020-10-14 13:29 ` Cyrill Gorcunov
2020-10-14 22:40 ` Vladislav Shpilevoy
2020-10-15 6:50 ` Cyrill Gorcunov
2020-10-13 23:28 ` Vladislav Shpilevoy [this message]
2020-10-13 23:28 ` [Tarantool-patches] [PATCH 4/6] raft: introduce on_update trigger Vladislav Shpilevoy
2020-10-13 23:28 ` [Tarantool-patches] [PATCH 5/6] raft: auto-commit transactions of the old leader Vladislav Shpilevoy
2020-10-13 23:28 ` [Tarantool-patches] [PATCH 6/6] qsync: reset confirmed lsn in limbo on owner change Vladislav Shpilevoy
2020-11-24 23:23 ` Vladislav Shpilevoy
2020-10-14 7:34 ` [Tarantool-patches] [PATCH 0/6] Raft auto-commit Serge Petrenko
2020-10-14 22:40 ` Vladislav Shpilevoy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=325b6fd1b87444f6cefdacf80e28cd9f692adb29.1602631481.git.v.shpilevoy@tarantool.org \
--to=v.shpilevoy@tarantool.org \
--cc=sergepetrenko@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH 3/6] raft: new candidate should wait for leader death' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox