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 7566E6EC5C; Wed, 14 Jul 2021 21:31:26 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7566E6EC5C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1626287486; bh=s0QwtRw1QM3xMa02QGb9JJDBX+ARXuVou1K0kgor7vA=; 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=f+g+IEzRejdg0eX+vSD03tGwT8XFwRTXR/ICTQw7ziM9tzDAN5E+Hfem/E91nK1Dc N2kKOLfl5xG5tZa7wBJE1ZPs9ZUarYWIxenPpOsL1rB38rk68t60bYLJuMNx5a5Cse /HFCYix3eANgv+H3EJT9WqX4eplqJxN7/X3kIM84= Received: from smtp58.i.mail.ru (smtp58.i.mail.ru [217.69.128.38]) (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 46DDF6F3CA for ; Wed, 14 Jul 2021 21:26:09 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 46DDF6F3CA Received: by smtp58.i.mail.ru with esmtpa (envelope-from ) id 1m3jaC-0007Q7-FC; Wed, 14 Jul 2021 21:26:08 +0300 To: v.shpilevoy@tarantool.org, gorcunov@gmail.com Date: Wed, 14 Jul 2021 21:25:39 +0300 Message-Id: <8f3da7c3f32f75bf2b38a01a02dabe31c59d5a1a.1626287002.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: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD97BB0EF39AD2B33D598226807B8A1E9DC331E3F9997896515182A05F5380850401D1C6F3ABE478D0AE1CBA9C09F57F16F412D8701842823E5CBF9C083BB68FEB4 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE743A67C3F703598BFEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637F757A79C3007ACA28638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8903999B633A4934C0E03A7860EBAAE32117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCEA77C8EAE1CE44B0A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F4460429728776938767073520B1593CA6EC85F86D6FD1C55BDD38FC3FD2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6D635BA3ABDB36C18089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CE68746B1F2AB10C653CA2C4BF114DCD97F4B3BD7C6DFC2D09C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF309DFB797F6729CB699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3473457D764E1CDE7712EB335C3A67FA6927C6DB319AC3547E3740BBE8A38F50B9F9A312683981D0251D7E09C32AA3244C67F85B804EA55E8B7E62B0A0D2F7BEA495A9E0DC41E9A4CF927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojDdSFIg49M1SH8+zb/HD6zw== X-Mailru-Sender: 3B9A0136629DC9125D61937A2360A446DCF67A6ACA5D040DFEE64EE5B4617CA41B022678D1B5C5C9424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v4 11/16] box: make promote on the current leader a no-op 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" It was allowed to call promote on any instance, even when it's already the limbo owner (iow Raft leader, when elections are enabled). This doesn't break anything, when elections are disabled, but is rather strange. When elections are enabled, in contrary, calling promote() should be a no-op on the leader. Otherwise it would make the leader read-only until it wins the next election round, which's quite inconvenient. Part-of #6034 --- src/box/box.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/box/box.cc b/src/box/box.cc index ac6c487e4..6a534952f 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -1701,6 +1701,9 @@ box_promote(void) */ if (!is_box_configured) return 0; + if (txn_limbo_replica_term(&txn_limbo, instance_id) == + box_raft()->term) + return 0; bool run_elections = false; bool try_wait = false; @@ -1729,10 +1732,6 @@ box_promote(void) "'candidate'", "manual elections"); return -1; } - if (txn_limbo_replica_term(&txn_limbo, instance_id) == - box_raft()->term) - return 0; - break; default: unreachable(); -- 2.30.1 (Apple Git-130)