From: Serge Petrenko via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: v.shpilevoy@tarantool.org, gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH v2 3/8] raft: refactor raft_new_term() Date: Fri, 18 Jun 2021 00:07:37 +0300 [thread overview] Message-ID: <2b1046032831ce0b2d19ae0e85d84e9eb8671818.1623963649.git.sergepetrenko@tarantool.org> (raw) In-Reply-To: <cover.1623963649.git.sergepetrenko@tarantool.org> Make raft_new_term() always bump the current term, even when Raft is disabled. Part-of #6034 --- src/box/box.cc | 2 +- src/lib/raft/raft.c | 3 +-- test/unit/raft.c | 15 ++++++++++++++- test/unit/raft.result | 3 ++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/box/box.cc b/src/box/box.cc index d6a3b4d97..6a0950f44 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -3514,7 +3514,7 @@ box_cfg_xc(void) if (!is_bootstrap_leader) { replicaset_sync(); - } else { + } else if (raft_is_enabled(box_raft())) { /* * When the cluster is just bootstrapped and this instance is a * leader, it makes no sense to wait for a leader appearance. diff --git a/src/lib/raft/raft.c b/src/lib/raft/raft.c index eacdddb7e..78d55846f 100644 --- a/src/lib/raft/raft.c +++ b/src/lib/raft/raft.c @@ -987,8 +987,7 @@ raft_cfg_vclock(struct raft *raft, const struct vclock *vclock) void raft_new_term(struct raft *raft) { - if (raft->is_enabled) - raft_sm_schedule_new_term(raft, raft->volatile_term + 1); + raft_sm_schedule_new_term(raft, raft->volatile_term + 1); } static void diff --git a/test/unit/raft.c b/test/unit/raft.c index 6369c42d3..4db4024d9 100644 --- a/test/unit/raft.c +++ b/test/unit/raft.c @@ -1176,7 +1176,7 @@ raft_test_death_timeout(void) static void raft_test_enable_disable(void) { - raft_start_test(10); + raft_start_test(11); struct raft_node node; raft_node_create(&node); @@ -1268,7 +1268,20 @@ raft_test_enable_disable(void) "{0: 2}" /* Vclock. */ ), "nothing changed"); + /* Disabled node still bumps the term when needed. */ + raft_node_new_term(&node); + + ok(raft_node_check_full_state(&node, + RAFT_STATE_FOLLOWER /* State. */, + 0 /* Leader. */, + 4 /* Term. */, + 0 /* Vote. */, + 4 /* Volatile term. */, + 0 /* Volatile vote. */, + "{0: 3}" /* Vclock. */ + ), "term bump when disabled"); raft_node_destroy(&node); + raft_finish_test(); } diff --git a/test/unit/raft.result b/test/unit/raft.result index 598a7e760..57229a265 100644 --- a/test/unit/raft.result +++ b/test/unit/raft.result @@ -203,7 +203,7 @@ ok 10 - subtests ok 11 - subtests *** raft_test_death_timeout: done *** *** raft_test_enable_disable *** - 1..10 + 1..11 ok 1 - accepted a leader notification ok 2 - leader is seen ok 3 - death timeout passed @@ -214,6 +214,7 @@ ok 11 - subtests ok 8 - became leader ok 9 - resigned from leader state ok 10 - nothing changed + ok 11 - term bump when disabled ok 12 - subtests *** raft_test_enable_disable: done *** *** raft_test_too_long_wal_write *** -- 2.30.1 (Apple Git-130)
next prev parent reply other threads:[~2021-06-17 21:10 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-06-17 21:07 [Tarantool-patches] [PATCH v2 0/8] forbid implicit limbo ownership transition Serge Petrenko via Tarantool-patches 2021-06-17 21:07 ` [Tarantool-patches] [PATCH v2 1/8] replication: always send raft state to subscribers Serge Petrenko via Tarantool-patches 2021-06-17 21:07 ` [Tarantool-patches] [PATCH v2 2/8] txn_limbo: fix promote term filtering Serge Petrenko via Tarantool-patches 2021-06-17 22:05 ` Cyrill Gorcunov via Tarantool-patches 2021-06-18 8:55 ` Serge Petrenko via Tarantool-patches 2021-06-18 10:31 ` Cyrill Gorcunov via Tarantool-patches 2021-06-21 15:09 ` Serge Petrenko via Tarantool-patches 2021-06-17 21:07 ` Serge Petrenko via Tarantool-patches [this message] 2021-06-17 21:07 ` [Tarantool-patches] [PATCH v2 4/8] box: make promote always bump the term Serge Petrenko via Tarantool-patches 2021-06-17 21:07 ` [Tarantool-patches] [PATCH v2 5/8] replication: forbid implicit limbo owner transition Serge Petrenko via Tarantool-patches 2021-06-17 21:07 ` [Tarantool-patches] [PATCH v2 6/8] box: introduce `box.ctl.demote` Serge Petrenko via Tarantool-patches 2021-06-17 21:15 ` Serge Petrenko via Tarantool-patches 2021-06-17 21:07 ` [Tarantool-patches] [PATCH v2 7/8] txn_limbo: persist the latest effective promote in snapshot Serge Petrenko via Tarantool-patches 2021-06-17 21:07 ` [Tarantool-patches] [PATCH v2 8/8] replication: send latest effective promote in initial join Serge Petrenko via Tarantool-patches 2021-06-18 13:02 ` [Tarantool-patches] [PATCH v2 0/8] forbid implicit limbo ownership transition Cyrill Gorcunov via Tarantool-patches 2021-06-21 12:11 ` [Tarantool-patches] [PATCH v2 9/8] replication: send current Raft term in join response Serge Petrenko via Tarantool-patches
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=2b1046032831ce0b2d19ae0e85d84e9eb8671818.1623963649.git.sergepetrenko@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=gorcunov@gmail.com \ --cc=sergepetrenko@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v2 3/8] raft: refactor raft_new_term()' \ /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