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 BA0856EC55; Sun, 18 Jul 2021 20:01:32 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BA0856EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1626627692; bh=0lZ6KcYYqn7D4wdMeMvH9b7+zu29LBBuVNryI3OSolI=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=bb0ZuUB1zqQt2Dt/NEgqAQYZeuIP+0kEJJPrlfzR/QY0MPgeBZZ1Zkhf2+2ncfr3J 8DIATnkpDn6IK/HwMChAMSx0yCjKJQ0KkyM/eAvB6rh858G09GTMGBCU/nDx5bU/bl ShxNtR6QSM4R2N5HVkSCJ6360NIqBagjmtW6+JRM= Received: from smtpng3.i.mail.ru (smtpng3.i.mail.ru [94.100.177.149]) (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 BA4A56EC56 for ; Sun, 18 Jul 2021 20:00:42 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BA4A56EC56 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1m5A9i-0002vy-6n; Sun, 18 Jul 2021 20:00:42 +0300 To: Serge Petrenko , tarantool-patches@dev.tarantool.org, gorcunov@gmail.com References: <911781cb-0aac-de47-3e08-e888b646a429@tarantool.org> Message-ID: <365e2e2d-4be6-4447-36a1-2a6a8ee4ab21@tarantool.org> Date: Sun, 18 Jul 2021 19:00:41 +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: <911781cb-0aac-de47-3e08-e888b646a429@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD941C43E597735A9C30288BCF456A452EC92BAB6D044D5CCDE182A05F538085040FD92E343E514A24259BB2B7C377E758E175291909B7013FDAEAE8BF20B0BBAEB X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE79D88886C873B3900EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006375E7A1B5661595F038638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D85CDB4887499F3CDCD66B3F4B36B798A7117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC292D688DDAD4E7BC389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8D2A98E5A6551E3E5117882F4460429728AD0CFFFB425014E868A13BD56FB6657E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637BC468E7E89D8C5D6EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A519CC66548B84789C88AF249F0A4DDE9B1A4C58CCC0C38251D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7501A9DF589746230F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D345C110A855FC099991196296D8C7953B8A8FAF906F53E784ED324915A07757704CEA0916E917E2AA81D7E09C32AA3244C3E6F70A44B0EF6B812AB798CB89026604DBEAD0ED6C55A80FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj+8+KVR9NZrG9eBK0207AlA== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DDD0865D8D2607D9DE79841B816CA06963841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 2/2] election: during bootstrap prefer candidates 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" Thanks for the review! >> diff --git a/src/box/box.cc b/src/box/box.cc >> index ef3efe3e0..3105b04b6 100644 >> --- a/src/box/box.cc >> +++ b/src/box/box.cc >> @@ -3519,7 +3519,30 @@ box_cfg_xc(void) >>            * should take the control over the situation and start a new >>            * term immediately. >>            */ >> -        raft_new_term(box_raft()); >> +        struct raft *raft = box_raft(); >> +        if (box_election_mode == ELECTION_MODE_MANUAL) { >> +            raft_start_candidate(raft); >> +            raft_new_term(raft); >> +            int rc = box_raft_wait_leader_found(); >> +            /* >> +             * No need to check if the mode is still manual - it >> +             * couldn't change because box.cfg is protected with a >> +             * fiber lock. >> +             */ >> +            assert(box_election_mode == ELECTION_MODE_MANUAL); >> +            raft_stop_candidate(raft, false); >> +            /* >> +             * It should not fail, because on bootstrap the node is >> +             * a single registered instance. It can't not win the >> +             * elections while being a lone participant. But still >> +             * check the result so as not to a ignore potential >> +             * problems. >> +             */ >> +            if (rc != 0) >> +                diag_raise(); >> +        } else { >> +            raft_new_term(raft); >> +        } > > Could you please extract this fix into a separate commit? Done. See v2. > Speaking of your problems with raft_try_candidate. I also can't think > of a good enough alternative. > > For promote it would be nice to do: > > do { >     raft_try_candidate_for_1_term(); > } while (leader is not known); > > and simply > raft_try_candidate_for_1_term(); > for bootstrap. > > But raft_try_candidate_for_1_term() looks hard to implement. Yes, I had something like that in mind too. I tried to implement it in v2.