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 BFD486EC58; Mon, 21 Jun 2021 17:56:12 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BFD486EC58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1624287372; bh=fgy52IPFNax/l0XTQfpUnT4CMyPZx8/moQa2pBtDiQE=; 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=WgLQV9OcNlNmlFoIM51UGXZbAivf69XbBWInX4jh10ONVrnPq6witUARbPHxyxrTh 755NM0/MwzHs/OiscBGuOHyKCexIDCbnzXsKbTabCoXOUfBqTVPJ44modGX0T02PpL 8FfCi564lmgJ9Pip1a2s10EaniDXFWm6sJbVXwc0= Received: from smtp30.i.mail.ru (smtp30.i.mail.ru [94.100.177.90]) (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 5977B6EC58 for ; Mon, 21 Jun 2021 17:56:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5977B6EC58 Received: by smtp30.i.mail.ru with esmtpa (envelope-from ) id 1lvLLO-00047G-GJ; Mon, 21 Jun 2021 17:56:10 +0300 To: Vladislav Shpilevoy , gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org References: <5fc6e8a222fc1a05ad45d90fb306fcfe4423d3f1.1623331925.git.sergepetrenko@tarantool.org> Message-ID: Date: Mon, 21 Jun 2021 17:56:09 +0300 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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD91C2C07775F13263A48BAE59A842244EB7433BA0B4B73D52900894C459B0CD1B9D066956FA182042D11EF2FB18C9E3EB210D5A1075979132AB4F73980836E4665 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7547428DA4700DDEFC2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE77F05ED334962579DEA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BD6CF32B5F8F9D404B07955A48EF5E962A417B57CD28E216ECC7F00164DA146DAFE8445B8C89999728AA50765F7900637D0FEED2715E18529389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8744B801E316CB65FF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA7E827F84554CEF5019E625A9149C048EE9ECD01F8117BC8BEE2021AF6380DFAD18AA50765F790063735872C767BF85DA227C277FBC8AE2E8B9149C560DC76099D75ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: 0D63561A33F958A52B87BF49EF560F4D15EF7D406F121F946F17E5C4A3787D96D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75448CF9D3A7B2C848410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D340D3A19269BBEBAAF6231FAD055DA25E47E5C6E683702667FE30071F23DF1E3EC9C4BA96D4C93C4A51D7E09C32AA3244C3C1B4E199147E236CBF767A0D2AA2669B4DF56057A86259FFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj8x+Gb+jwA+Rwd/jLKyEljw== X-Mailru-Sender: 3B9A0136629DC9125D61937A2360A446917F80AF373F7DB08761825A03EC75EA021BB5E22858DE25424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 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: Serge Petrenko via Tarantool-patches Reply-To: Serge Petrenko Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 19.06.2021 01:52, Vladislav Shpilevoy пишет: > Thanks for the patch! > > See 3 comments below. Thanks for the review! >> 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 Fixed. > >> 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. Sure, fixed. Please find the diff below. > >> @@ -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. > Ok, I see. Maybe rename `box.ctl.demote()` to something else? The notorious `clear_synchro_queue`, for example. This way the user won't expect the function to demote a leader. I intended the function to be used as PROMOTE for replica id 0, i.e. someone has to become the leader before writing PROMOTE/DEMOTE. This means both functions result in electing a leader. But for a different purpose: either to pin the limbo to it, or free the limbo from any other owner. ================================================= diff --git a/src/box/box.cc b/src/box/box.cc index f2bde910c..44ee327e9 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -1533,7 +1533,8 @@ box_clear_synchro_queue(bool demote)         /* A guard to block multiple simultaneous function invocations. */         static bool in_promote = false;         if (in_promote) { -               diag_set(ClientError, ER_UNSUPPORTED, "box.ctl.promote", +               diag_set(ClientError, ER_UNSUPPORTED, +                        demote ? "box.ctl.demote" : "box.ctl.promote",                          "simultaneous invocations");                 return -1;         } ================================================= -- Serge Petrenko