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 A231A6F87A; Fri, 16 Apr 2021 18:50:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A231A6F87A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1618588231; bh=/ac68X+VC4YHrNuZHf5nrjZODcugJrKNLR2uUQWIyjo=; 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=ocloO1+FU8hBG4Vfs/IYbKPe0LvK4ezDZhz6hXjWiWEU7jSdbunbqhO/Xf+K+Or6d VfsrJFcpyeWnLBTLSFELYO3bhpBgJm5hEJI5aGDi7Iw39/B5v5xAZLVLaglYjkyIvF xYvpFPcVvgIi8YYZOXCty5q5CqJ7VBjzV60dLYFk= Received: from smtp31.i.mail.ru (smtp31.i.mail.ru [94.100.177.91]) (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 28F306F87A for ; Fri, 16 Apr 2021 18:50:30 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 28F306F87A Received: by smtp31.i.mail.ru with esmtpa (envelope-from ) id 1lXQjl-0004Z1-J4; Fri, 16 Apr 2021 18:50:29 +0300 To: Vladislav Shpilevoy , gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org References: <815ca075-7d25-a584-b75a-9a4a28e6cdaf@tarantool.org> Message-ID: Date: Fri, 16 Apr 2021 18:50:29 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: <815ca075-7d25-a584-b75a-9a4a28e6cdaf@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92FFCB8E6708E74800BD71C2E2CF43DDE8CBA234A641A13D4182A05F53808504069E543B466BF9E0D10B0D9EE580B3A05A9811C9B727A22ABEC9D7D41B08D6F01 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE76C42F509AB58C142EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006373DBA3D7E24987517EA1F7E6F0F101C67CDEEF6D7F21E0D1D9295C2E9FA3191EE1B59CA4C82EFA65894BF3CC9E5BD2CFB0D27B8F2E439B0D8F6B57BC7E64490618DEB871D839B73339E8FC8737B5C2249E232F00D8D26902CA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F4460429728776938767073520B1593CA6EC85F86DBDFBBEFFF4125B51D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE38D4DC57D478E6880CB8D3112395442FD8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE3A6C7FFFE744CA7FB6E0066C2D8992A16C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD18AA50765F790063735872C767BF85DA227C277FBC8AE2E8B9149C560DC76099D75ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: 0D63561A33F958A512D109B9BB6426D239AB104D735F3957B29B9FEACC499AD4D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3498910055B812BD9C97A39940A9F57F29BCCB3F9DED21ED91616F11C6C7C6BAE6DECA6D96AC6706381D7E09C32AA3244C8A5EFD3D8D7E6FB68699F3E67039851C7101BF96129E4011FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj3S6P1v0GIqSfTFLh1ruFfg== X-Mailru-Sender: 583F1D7ACE8F49BDD2846D59FC20E9F8FCCAEE64D139E14D0DB5C064D99621EB58B5FD13E11082C2424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v3 08/10] Support manual elections in `box.ctl.clear_synchro_queue()` 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 Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 16.04.2021 18:40, Serge Petrenko via Tarantool-patches пишет: > > > 16.04.2021 18:38, Serge Petrenko via Tarantool-patches пишет: >> >> >> 16.04.2021 02:30, Vladislav Shpilevoy пишет: >>>> diff --git a/src/box/raft.h b/src/box/raft.h >>>> index 15f4e80d9..8fce423e1 100644 >>>> --- a/src/box/raft.h >>>> +++ b/src/box/raft.h >>>> @@ -97,6 +97,9 @@ box_raft_checkpoint_remote(struct raft_request >>>> *req); >>>>   int >>>>   box_raft_process(struct raft_request *req, uint32_t source); >>>>   +void >>>> +box_raft_wait_leader_found(); >>>> + >>>>   void >>>>   box_raft_init(void); >>>>   diff --git a/src/lib/raft/raft.c b/src/lib/raft/raft.c >>>> index e9ce8cade..7b77e05ea 100644 >>>> --- a/src/lib/raft/raft.c >>>> +++ b/src/lib/raft/raft.c >>>> @@ -846,7 +846,7 @@ raft_cfg_is_enabled(struct raft *raft, bool >>>> is_enabled) >>>>   } >>>>     void >>>> -raft_cfg_is_candidate(struct raft *raft, bool is_candidate) >>>> +raft_cfg_is_candidate(struct raft *raft, bool is_candidate, bool >>>> demote) >>> 5. I know it might lead to some code duplication, but probably >>> better move that to other functions. For example, >>> >>>     raft_cfg_is_temporary_candidate() >>> >>> or something like that. Otherwise it appears surprisingly hard >>> to follow these 2 flags together. Although I might be wrong and >>> it would look worse. Did you try? >>> >>> Or another option: >>> >>>     raft_cfg_is_candidate(box_raft(), true, false); >>>     raft_cfg_is_candidate(box_raft(), false, false); >>> >>> turns into >>> >>>     raft_start_candidate(box_raft()) >>>     raft_stop_candidate(box_raft()) >>> >>> Also it would be good to have unit tests for the changes in raft.h >>> and raft.c. >> >> This variant sounds good. I'll implement in in a new commit. > > The commit I was talking about: Incremental diff on top: ===================================== diff --git a/src/lib/raft/raft.c b/src/lib/raft/raft.c index 8deb06eb5..b21693642 100644 --- a/src/lib/raft/raft.c +++ b/src/lib/raft/raft.c @@ -862,7 +862,13 @@ raft_start_candidate(struct raft *raft)         if (raft->is_candidate)                 return;         raft->is_candidate = true; -       assert(raft->state == RAFT_STATE_FOLLOWER); +       assert(raft->state != RAFT_STATE_CANDIDATE); +       /* +        * May still be the leader after raft_stop_candidate +        * with demote = false. +        */ +       if (raft->state == RAFT_STATE_LEADER) +               return;         if (raft->is_write_in_progress) {                 /*                  * If there is an on-going WAL write, it means there was -- Serge Petrenko