From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id E73B46E201; Fri, 18 Jun 2021 00:10:17 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E73B46E201 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1623964218; bh=fLD5xicsPCSBHkaxxAIeo9/ks0MxFS7fdwpcMwU2GDA=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=M6MqDJH8tnzEIrvLonirHMfrwfFcRRKCxoPi9ZO8gDNcTdEr2+JxSs5Xy0FtdQz/d kXtj6AY3GPo2WDfrm7ebEpG955W1mYT4h3dWN3NZfXrKgcjFYOooc1W7MsCfwEQ3Jk U61i/lGN08L9pd8irsOlG+Pvo5ZRfxVNP5WJOPUQ= Received: from smtp46.i.mail.ru (smtp46.i.mail.ru [94.100.177.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 829116E203 for ; Fri, 18 Jun 2021 00:08:43 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 829116E203 Received: by smtp46.i.mail.ru with esmtpa (envelope-from ) id 1ltzFi-00046o-NK; Fri, 18 Jun 2021 00:08:43 +0300 To: v.shpilevoy@tarantool.org, gorcunov@gmail.com Date: Fri, 18 Jun 2021 00:07:37 +0300 Message-Id: <2b1046032831ce0b2d19ae0e85d84e9eb8671818.1623963649.git.sergepetrenko@tarantool.org> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD91C2C07775F13263A48BAE59A842244EB7433BA0B4B73D52900894C459B0CD1B938B557222F2E9612CE927452BF7854D77FF79ED123BE076CC3F62BCCD34CAD73 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7E001CCFF7904EF03EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006374FA524FBD8B89EAA8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8A940AEC2B476A5A85BDABB3205B3624A117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC55B19328CBC4F849A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F4460429728776938767073520140C956E756FBB7AE5D25F19253116ADD2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE22A4E020D69BCAC1B1CA5D0BF4193578D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE3B2DECCBDF547A30576E601842F6C81A1F004C906525384307823802FF610243DF43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7CAA44A86D94E7BBB043847C11F186F3C59DAA53EE0834AAEE X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2368A440D3B0F6089093C9A16E5BC824A2A04A2ABAA09D25379311020FFC8D4AD7067FEF890167A54237BA400185E3453 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C2C9C2AE8C25C43DD66DDFAF139E0208187B40DF9DFE769789C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EFD99FB7B2A39B4961699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34987A0E8D235BB5344F112E6AE247F4CDC28EE6203B477C198CB5319295E178E27201EF4C76AC3D4B1D7E09C32AA3244C99E950C9504D85865AB32300C8EA16ED55E75C8D0ED9F6EE927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbL9S8ysBdXjymZAW17GbhLNCkfzSKWmh X-Mailru-Sender: 583F1D7ACE8F49BD9DF7A8DAE6E2B08A18ACA3F90167714148640C1B29E6CE3E8897E28B5351C242424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v2 3/8] raft: refactor raft_new_term() X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Serge Petrenko via Tarantool-patches Reply-To: Serge Petrenko Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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)