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 449996EC40; Tue, 29 Jun 2021 01:16:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 449996EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1624918588; bh=qXjuN851q2vbJIn2vFfk36JJMh3Q7dhvlSyuA5w4Wrc=; 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=T37EsVIME2Pl/yeAEwpINRZ064nEglZ9HuJYKdLzZOSNyhOHNXFDZItDIXa9CED5m z/3C/8LBUojJwHeLowNlEf4KQ0zDzc8mG25m6ptq72SentaOBM7IpgR0TfA86l48rS t5FJOmHUMbGsaqiPs8oUxlW+tf0R5A9nYKMII+e0= Received: from smtp61.i.mail.ru (smtp61.i.mail.ru [217.69.128.41]) (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 712816EC41 for ; Tue, 29 Jun 2021 01:13:16 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 712816EC41 Received: by smtp61.i.mail.ru with esmtpa (envelope-from ) id 1lxzVD-0007oC-NF; Tue, 29 Jun 2021 01:13:16 +0300 To: v.shpilevoy@tarantool.org, gorcunov@gmail.com Date: Tue, 29 Jun 2021 01:12:52 +0300 Message-Id: <7b48222da26b4dc51ff4f30b3dac81de3c4b63a2.1624918077.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: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD954DFF1DC42D673FB4F75AC5594ACDC16869A51A860A12816182A05F538085040DA378C123AE0213629F30E4FA478DF0BA9D60F4D885CAD0302404EAAFE44B5E3 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE758EB3DA2633E2854EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637D4360D888D8F9BE48638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D860801EE91D4C4EC99BC2C7A9BF29158F117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAE9A1BBD95851C5BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735209647ADFADE5905B1C26CFBAC0749D213D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B60A62CEF541B197C8089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2AD77751E876CB595E8F7B195E1C97831A91E565E6410D4C455037634962608ED X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CD87436A60A035F40E1BC58CB323A55E7E1D3B4C35B183BE39C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF92B0BE0DA6BB795D699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D346B1FF97F6D0959A2BDF3D8C96E154FAF737E907152E89AF6E7B66BB2F807FDD64B584FA0DB7E834A1D7E09C32AA3244C4EBA83FE0650ED0B6EE851659A36252835DA7DC5AF9B58C0927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojNjLyMoNI2JY9llwIO80isA== X-Mailru-Sender: 3B9A0136629DC9125D61937A2360A446C3FEE19542AA4C0E8D726894FA23433BE3918863165B4F1C424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v3 06/12] box: allow calling promote on a candidate 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" Part of #6034 --- src/box/box.cc | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/src/box/box.cc b/src/box/box.cc index ce37b307d..1d894be97 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -1538,11 +1538,6 @@ box_promote(void) return -1; } - /* - * Do nothing when box isn't configured and when PROMOTE was already - * written for this term (synchronous replication and leader election - * are in sync, and both chose this node as a leader). - */ if (!is_box_configured) return 0; bool run_elections = false; @@ -1558,21 +1553,13 @@ box_promote(void) "manual elections"); return -1; case ELECTION_MODE_MANUAL: - if (box_raft()->state == RAFT_STATE_LEADER) - return 0; - run_elections = true; - break; case ELECTION_MODE_CANDIDATE: + run_elections = box_raft()->state != RAFT_STATE_LEADER; /* - * Leader elections are enabled, and this instance is allowed to - * promote only if it's already an elected leader. No manual - * elections. + * Do nothing when PROMOTE was already written for this term + * (synchronous replication and leader election are in sync, and + * both chose this node as a leader). */ - if (box_raft()->state != RAFT_STATE_LEADER) { - diag_set(ClientError, ER_UNSUPPORTED, "election_mode=" - "'candidate'", "manual elections"); - return -1; - } if (txn_limbo_replica_term(&txn_limbo, instance_id) == box_raft()->term) return 0; -- 2.30.1 (Apple Git-130)