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 A16536EC58; Tue, 25 May 2021 13:40:08 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A16536EC58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1621939208; bh=5AdhJr9/ILHa77UN7bTrvybj/hkvEvuDEB2QWZ+CbP8=; 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=HBWVAy8OpjnOg6lHu/SWJZVkT2ok3eoNV72zVUcgDzbbENIeiesB1e9ckPa/sHMQN V0VyCAc2WA6EHskZUwiWig4mKXXwhuNZt2Nh7qJ4WUe0MJXsFEToXhgnC8Oh7zC8Jl hhbj4AoVYArqS5HzAkIXUjLTTs49TICAKuvgNgs4= Received: from smtp35.i.mail.ru (smtp35.i.mail.ru [94.100.177.95]) (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 EAFA26EC5F for ; Tue, 25 May 2021 13:39:33 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org EAFA26EC5F Received: by smtp35.i.mail.ru with esmtpa (envelope-from ) id 1llUTF-0002vj-5V; Tue, 25 May 2021 13:39:33 +0300 To: v.shpilevoy@tarantool.org, gorcunov@gmail.com Date: Tue, 25 May 2021 13:39:28 +0300 Message-Id: <913a4471008f32c4f9448f25ae54c3de6ee2f249.1621935783.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-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD91B019B01C53E51AF07EDA974EE11B688BBB65244C6A6BC9F00894C459B0CD1B9CED1E0C34A3971F1ED47268D204CC0400BC1D0E047EE27F5AFE7A561BD4DB76D X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE777C0165395C6E072EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637A521848D7B067A388638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D81576C8A616EA89561049A9EA0307C7FA117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCECADA55FE5B58BB7A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751F28451B159A507268D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B67ECBC18655D52CDF089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CDFB9373DB28FDDFB4060AB52C6208A33E4E1959D87F92A1D9C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF92B0BE0DA6BB795D699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D348E5EF936B2E46EBA153B4F53AEDEA035BAABA874A7EC0E8BB48E88A42E716112D13877D07FB623041D7E09C32AA3244C39D7D6529E00CFBC9234F6F8A66BE475F2F5F14F68F1805B927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojV3CWresp27c7c64ZQSydAQ== X-Mailru-Sender: 3B9A0136629DC9125D61937A2360A446C5C3ACC23E232AA653D5C541D8E8E871D126F917A4825BD6424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v2 1/2] box: refactor in_promote using a guard 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" --- src/box/box.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/box/box.cc b/src/box/box.cc index c10e0d8bf..894e3d0f4 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -1562,6 +1562,9 @@ box_promote(void) int rc = 0; int quorum = replication_synchro_quorum; in_promote = true; + auto promote_guard = make_scoped_guard([&] { + in_promote = false; + }); if (run_elections) { /* @@ -1581,19 +1584,15 @@ box_promote(void) */ if (box_election_mode == ELECTION_MODE_MANUAL) raft_stop_candidate(box_raft(), false); - if (rc != 0) { - in_promote = false; + if (rc != 0) return -1; - } if (!box_raft()->is_enabled) { diag_set(ClientError, ER_RAFT_DISABLED); - in_promote = false; return -1; } if (box_raft()->state != RAFT_STATE_LEADER) { diag_set(ClientError, ER_INTERFERING_PROMOTE, box_raft()->leader); - in_promote = false; return -1; } } @@ -1617,7 +1616,6 @@ box_promote(void) if (former_leader_id != txn_limbo.owner_id) { diag_set(ClientError, ER_INTERFERING_PROMOTE, txn_limbo.owner_id); - in_promote = false; return -1; } } @@ -1658,7 +1656,6 @@ promote: assert(txn_limbo_is_empty(&txn_limbo)); } } - in_promote = false; return rc; } -- 2.30.1 (Apple Git-130)