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 64AFC6EC58; Sun, 1 Aug 2021 19:19:42 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 64AFC6EC58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1627834782; bh=kwJhAnW6dhbULJI956dVHBuYOFdgTTxp2OVIXbcwUuo=; h=To:Cc:References:Date:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=kaoVqGOn50C/INMCblPR4aMnUACTyaaT80ScBL0ngMkeyTgjGmPvlI0hvrfjXRdkZ /Wdzosf67HO+NvfW8nndZwfabTT8l70WgDNCmvI3RdMkiWf6JViH3VnNIxgxrFiDKI SdBGUj6fcbMsdiFX8pPjbH21pc0n7mSeou5UNosw= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (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 639C26EC58 for ; Sun, 1 Aug 2021 19:19:41 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 639C26EC58 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mAEBg-0005Es-M1; Sun, 01 Aug 2021 19:19:41 +0300 To: Sergey Petrenko , gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org References: <3b4f7752-f68b-afce-c83a-355bcfbc28cc@tarantool.org> <9ae5765f-ffcb-af66-469b-b0a99d71c331@tarantool.org> <036d7d32-54bc-3239-9291-d713b062f324@tarantool.org> Message-ID: Date: Sun, 1 Aug 2021 18:19:39 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD941C43E597735A9C3FDAB68B812060C77E97CF8617D978122182A05F538085040B587933851B816BA232ED1F6D01C0811991D4AA9F187B4CE97ABB853B932E306 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7E562D89B91CB6482EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637329F9579A0E72DCC8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D84E3E9811A9A876B0EDBA71399C63031D117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC8C7ADC89C2F0B2A5A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751FC26CFBAC0749D213D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B613439FA09F3DCB32089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A50BBDB2DE5E0D2BB51D3559DB2E8553C9AD21336D7F3E2FB1D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA751B940EDA0DFB0535410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3488E5CD2E691F55664DA585FB3ACCD1449EE113FF430DD8FAA66029A8F2EA63AB2691D92807D48C461D7E09C32AA3244C4CB313879A9D17988E9234ACEA63DE3933C9DC155518937FFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojMCfuYI4PredJKkT5qJA9Pg== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DE27A2A3A64ACCCC4CBF5B2214C8DA30F3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v3 07/12] box: introduce `box.ctl.demote` 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: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi! Thanks for the patch! I think we are on the finish line here, see 4 small comments below. After them and after you fix the failing vinyl test, the patchset will probably be finished! There are only 2 things which bother me. They are not bugs and we can work on them in the next quarter. 1) Assume you have election_mode = 'manual'. And you are a leader. You call box.ctl.demote() and stop being a leader. But the limbo is still yours. If now you switch election_mode to 'off', you need to call box.ctl.demote() again to free the limbo. 2) In the last commit I see we make too much actions to ensure we are a writable leader. Perhaps in the future we should not report box.info.election.state == 'leader' until promote is written and should not say the instance is writable. I don't have a plan for either of these ideas yet. > diff --git a/src/box/box.cc b/src/box/box.cc > index 41f665e38..a34e05e94 100644 > --- a/src/box/box.cc > +++ b/src/box/box.cc > @@ -1679,20 +1679,44 @@ box_issue_promote(uint32_t prev_leader_id, int64_t promote_lsn) > assert(txn_limbo_is_empty(&txn_limbo)); > } > > +/* A guard to block multiple simultaneous box_promote() invocations. */ 1. For out of function comments we usually use /** as an opening. > +static bool in_box_promote = false; 2. Could you please use `is_` prefix here? `is_in_box_promote`. > + > +int > +box_promote_qsync(void) > +{ > + assert(!in_box_promote); > + assert(is_box_configured); > + struct raft *raft = box_raft(); > + in_box_promote = true; > + auto promote_guard = make_scoped_guard([&] { > + in_box_promote = false; > + }); > + if (raft->state != RAFT_STATE_LEADER) > + return 0; 3. This condition is not reachable, according to what I see in box_raft_worker_f(). > + assert(box_election_mode == ELECTION_MODE_MANUAL || > + box_election_mode == ELECTION_MODE_CANDIDATE); > + if (txn_limbo_replica_term(&txn_limbo, instance_id) == raft->term) > + return 0; > + int64_t wait_lsn = box_wait_limbo_acked(TIMEOUT_INFINITY); > + if (wait_lsn < 0) > + return -1; 4. Perhaps this better be panic? Because infinity timeout should not ever be reached. And then the function becomes void, because would not be able to fail anymore. > + box_issue_promote(txn_limbo.owner_id, wait_lsn); > + return 0; > +} > commit 7980cb3096f2616a2851f8d97db8091f0d82879c > Author: Serge Petrenko > Date: Mon Jun 28 11:52:44 2021 +0300 > > box: allow calling promote on a candidate > > Part of #6034 > > diff --git a/test/replication/gh-6034-election-candidate-promote.result b/test/replication/gh-6034-election-candidate-promote.result > new file mode 100644 > index 000000000..2b4bc0213 > --- /dev/null > +++ b/test/replication/gh-6034-election-candidate-promote.result 5. The test name format `gh-####-...` is obligatory only for bug tests. This patch seems to be adding a feature.