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 510276E200; Sat, 19 Jun 2021 01:53:02 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 510276E200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1624056782; bh=mNVA2yBrCUyWqrwboewGdM4VP5th5N0S6j1geStsZ78=; 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=h4dotAmNWp4ZCi75uGjrlrkN2tI3B0Ps5wOR+1spyQ3F5YyqaoxTUfOy3RxgJHg5q 0QKZmT9VzeSOd8QruB8TMXQBP0YpKZZ//3MzNY7Wa6bjB+aACTZ4MlOJy/TF/GUrcX /GecTr1fx9Lpe+k6QB/kZTOO4bBhNzxA/wG90pXg= Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [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 2BF306E200 for ; Sat, 19 Jun 2021 01:53:01 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 2BF306E200 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1luNMC-0001D2-Fn; Sat, 19 Jun 2021 01:53:00 +0300 To: Serge Petrenko , gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org References: <5fc6e8a222fc1a05ad45d90fb306fcfe4423d3f1.1623331925.git.sergepetrenko@tarantool.org> Message-ID: Date: Sat, 19 Jun 2021 00:52:59 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <5fc6e8a222fc1a05ad45d90fb306fcfe4423d3f1.1623331925.git.sergepetrenko@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD91C2C07775F13263AD4A2A3BFBC817E640615893838B9A94F00894C459B0CD1B94AE47554F3B705AAAF1632D7EAA862751423CBEC9FF1E7EFCF9BE0995F4686B4 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7CD7ADFD33CE41673EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063724170451E8B6ECF78638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D854E7B69EC8234680A15CCFA27F63C3F3117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC974A882099E279BDA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751FF04B652EEC242312D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B65D56369A3576CBA5089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2AD77751E876CB595E8F7B195E1C978311E0918C89E3BCC3411447ED96C72CD2D X-C1DE0DAB: 0D63561A33F958A52FDCAD4821F01B8F2E5FC7190E99F74A1A7B255A4ED74C14D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75448CF9D3A7B2C848410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34EB7BD66E9101C100D81BFF155581C66607467318635394840D2BBE50D8DF2730B861DE0613856D351D7E09C32AA3244C2B6BDED7D5717767CCF4B4C2B47834AF4DBEAD0ED6C55A80FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj0Roc5o5ut96MqEEQTYfosA== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822F9665760855CEC7D6CB106240A64D08F3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 6/7] 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" Thanks for the patch! See 3 comments below. > box: introduce `box.ctl.demote` > > Introduce a new journal entry, DEMOTE. The entry has the same meaning as > PROMOTE, with the only difference that it clears limbo ownership instead > of transferring it to the issuer. > > Introduce `box.ctl.demote`, which works exactly like `box.ctl.promote`, > but results in writing DEMOTE instead of PROMOTE. > > A new request was necessary instead of simply writing PROMOTE(origin_id > = 0), because origin_id is deduced from row.replica_id, which cannot be > 0 for replicated rows (it's always equal to instance_id of the row > originator). > > Closes #6034 > > @TarantoolBod document 1. TarantoolBod -> TarantoolBot > Title: box.ctl.demote > > `box.ctl.demote()` is a new function, which works exactly like > `box.ctl.promote()`, with one exception that it results in the instance > writing DEMOTE request to WAL instead of a PROMOTE request. > > A DEMOTE request (DEMOTE = 32) copies PROMOTE behaviour (it clears the > limbo as well), but clears limbo ownership instead of assigning it to a > new instance. > > diff --git a/src/box/box.cc b/src/box/box.cc > index 53a8f80e5..f2bde910c 100644 > --- a/src/box/box.cc > +++ b/src/box/box.cc > @@ -1527,8 +1527,8 @@ box_wait_quorum(uint32_t lead_id, int64_t target_lsn, int quorum, > return 0; > } > > -int > -box_promote(void) > +static int > +box_clear_synchro_queue(bool demote) > { > /* A guard to block multiple simultaneous function invocations. */ > static bool in_promote = false; 2. A few lines below there is an error message about simultaneous invocations. It still talks only about promote(), but I think it should mention demote() too. > @@ -1691,10 +1691,16 @@ promote: 3. That looks strange. tarantool> box.cfg{election_mode = 'candidate'} tarantool> box.info.election --- - state: leader vote: 1 leader: 1 term: 2 ... tarantool> box.ctl.demote() --- ... tarantool> box.info.election --- - state: leader vote: 1 leader: 1 term: 2 ... So demote() didn't demote the leader nor raised an error. I would rather expect from demote() that it can be called only on the leader, and always makes it a follower. Even if the node is mode='candidate' and would elect itself again, still I would think it should step down in the current term.