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 19C716EC5B; Mon, 12 Apr 2021 22:25:00 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 19C716EC5B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1618255500; bh=EP30BwzCIphyrk8+doJ8iEyxB6bzbl6zRaX0Xrlo0qI=; 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=G3F1BSdQosd5aeSTcVdrKOAbYbBa5XZLe1wnOH18fZ66BsuGAMMrdQDCdtP5AhstC 7L1t7A+eYShloDUqQ/V7RzHICjjb2OA3sQTnwKms6VJLdAjd2SH28PVQHnMum1IOwp OmoWZAE4jRvIKT8syUofITHb5RAVhZev75g+7AfM= Received: from smtp49.i.mail.ru (smtp49.i.mail.ru [94.100.177.109]) (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 599F76EC5B for ; Mon, 12 Apr 2021 22:24:58 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 599F76EC5B Received: by smtp49.i.mail.ru with esmtpa (envelope-from ) id 1lW2B7-00047G-NP; Mon, 12 Apr 2021 22:24:58 +0300 To: v.shpilevoy@tarantool.org, gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org References: Message-ID: <045f1540-c418-b5c4-322b-79351e1e724c@tarantool.org> Date: Mon, 12 Apr 2021 22:24:57 +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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92FFCB8E6708E7480257C85EA0BB7A95D0F00AE41BB9A5343182A05F538085040AB8888FE79D03DF7A5AC701C9B4D8C0A0E55A46A3AD3A20044810BFBF7182EDC X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE773B48C5C644929D8EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637A164EE347039141E8638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B209716B5A9EF220E8CAE88FC27DF7C3588FE4E5499B132CBCD2E47CDBA5A96583C09775C1D3CA48CFCA5A41EBD8A3A0199FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3CA5A41EBD8A3A0199FA2833FD35BB23DF004C90652538430302FCEF25BFAB3454AD6D5ED66289B5278DA827A17800CE7CD6F8C649E2A8AB9D32BA5DBAC0009BE395957E7521B51C20BC6067A898B09E4090A508E0FED6299176DF2183F8FC7C01708D93AEE016C95CD04E86FAF290E2D7E9C4E3C761E06A71DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C30584FF81F342DA0735872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A24209795067102C07E8F7B195E1C978318F381D17C8BD0394654CE1D82DC659E2 X-C1DE0DAB: 0D63561A33F958A586894702A767380115EF7D406F121F94172785A1ED308D33D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3403182E70AE6895E0082A3F749375770BA3583DA73B63C18636CDDC010CA66854FCAF17D7106C222E1D7E09C32AA3244C604D973F3A0A2021AE88AFC1F8660F1551E887DA02A9F7BFFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojq8JA+pXcDumdIzd2Ts+mhw== X-Mailru-Sender: 583F1D7ACE8F49BDD2846D59FC20E9F87D43C2A30FCA8BFFFB7815912EC095B084E6363C6D3D4677424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 9/9] box.ctl: rename clear_synchro_queue to promote 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" 11.04.2021 20:56, Serge Petrenko пишет: > New function name will be `box.ctl.promote()`. It's much shorter and > closer to the function's now enriched functionality. > > Old name `box.ctl.clear_synchro_queue()` remains in Lua for the sake of > backward compatibility. > > Follow-up #5445 > Closes #3055 > > @TarantoolBot document > Title: deprecate `box.ctl.clear_synchro_queue()` in favor of `box.ctl.promote()` > > Replace all the mentions of `box.ctl.clear_synchro_queue()` with > `box.ctl.promote()` and add a note that `box.ctl.clear_synchro_queue()` > is a deprecated alias to `box.ctl.promote()` > Force-pushed a test. Please find an incremental diff below and the full patch in v2. ====================================== diff --git a/test/replication/election_basic.result b/test/replication/election_basic.result index d5320b3ff..78c911245 100644 --- a/test/replication/election_basic.result +++ b/test/replication/election_basic.result @@ -108,6 +108,31 @@ assert(box.info.election.leader == box.info.id)   | - true   | ... +-- Manual election mode. A voter most of the time, a leader once +-- `box.ctl.promote()` is called. +box.cfg{election_mode = 'manual'} + | --- + | ... + +assert(box.info.election.state == 'follower') + | --- + | - true + | ... +term = box.info.election.term + | --- + | ... +box.ctl.promote() + | --- + | ... +assert(box.info.election.state == 'leader') + | --- + | - error: assertion failed! + | ... +assert(box.info.election.term > term) + | --- + | - error: assertion failed! + | ... +  box.cfg{ \      election_mode = 'off',                                                      \      election_timeout = old_election_timeout                                     \ diff --git a/test/replication/election_basic.test.lua b/test/replication/election_basic.test.lua index 821f73cea..5fc398848 100644 --- a/test/replication/election_basic.test.lua +++ b/test/replication/election_basic.test.lua @@ -39,6 +39,16 @@ assert(box.info.election.term > term)  assert(box.info.election.vote == box.info.id)  assert(box.info.election.leader == box.info.id) +-- Manual election mode. A voter most of the time, a leader once +-- `box.ctl.promote()` is called. +box.cfg{election_mode = 'manual'} + +assert(box.info.election.state == 'follower') +term = box.info.election.term +box.ctl.promote() +assert(box.info.election.state == 'leader') +assert(box.info.election.term > term) +  box.cfg{ \      election_mode = 'off',                                                      \      election_timeout = old_election_timeout                                     \ diff --git a/test/replication/gh-3055-election-promote.result b/test/replication/gh-3055-election-promote.result new file mode 100644 index 000000000..6f5af13bc --- /dev/null +++ b/test/replication/gh-3055-election-promote.result @@ -0,0 +1,105 @@ +-- test-run result file version 2 +test_run = require('test_run').new() + | --- + | ... + +-- +-- gh-3055 box.ctl.promote(). Call on instance with election_mode='manual' +-- in order to promote it to leader. +SERVERS = {'election_replica1', 'election_replica2', 'election_replica3'} + | --- + | ... +-- Start in candidate state in order for bootstrap to work. +test_run:create_cluster(SERVERS, 'replication', {args='2 0.1 candidate'}) + | --- + | ... +test_run:wait_fullmesh(SERVERS) + | --- + | ... + +cfg_set_manual =\ +    "box.cfg{election_mode='manual'} "..\ +    "assert(box.info.election.state == 'follower') "..\ +    "assert(box.info.ro)" + | --- + | ... + +for _, server in pairs(SERVERS) do\ +    ok, res = test_run:eval(server, cfg_set_manual)\ +    assert(ok)\ +end + | --- + | ... + +-- Promote without living leader. +test_run:switch('election_replica1') + | --- + | - true + | ... +assert(box.info.election.state == 'follower') + | --- + | - true + | ... +term = box.info.election.term + | --- + | ... +box.ctl.promote() + | --- + | ... +assert(box.info.election.state == 'leader') + | --- + | - true + | ... +assert(not box.info.ro) + | --- + | - true + | ... +assert(box.info.election.term > term) + | --- + | - true + | ... + +-- Test promote when there's a live leader. +test_run:switch('election_replica2') + | --- + | - true + | ... +term = box.info.election.term + | --- + | ... +assert(box.info.election.state == 'follower') + | --- + | - true + | ... +assert(box.info.ro) + | --- + | - true + | ... +assert(box.info.election.leader ~= 0) + | --- + | - true + | ... +box.ctl.promote() + | --- + | ... +assert(box.info.election.state == 'leader') + | --- + | - true + | ... +assert(not box.info.ro) + | --- + | - true + | ... +assert(box.info.election.term > term) + | --- + | - true + | ... + +-- Cleanup. +test_run:switch('default') + | --- + | - true + | ... +test_run:drop_cluster(SERVERS) + | --- + | ... diff --git a/test/replication/gh-3055-election-promote.test.lua b/test/replication/gh-3055-election-promote.test.lua new file mode 100644 index 000000000..cbc3ed206 --- /dev/null +++ b/test/replication/gh-3055-election-promote.test.lua @@ -0,0 +1,43 @@ +test_run = require('test_run').new() + +-- +-- gh-3055 box.ctl.promote(). Call on instance with election_mode='manual' +-- in order to promote it to leader. +SERVERS = {'election_replica1', 'election_replica2', 'election_replica3'} +-- Start in candidate state in order for bootstrap to work. +test_run:create_cluster(SERVERS, 'replication', {args='2 0.1 candidate'}) +test_run:wait_fullmesh(SERVERS) + +cfg_set_manual =\ +    "box.cfg{election_mode='manual'} "..\ +    "assert(box.info.election.state == 'follower') "..\ +    "assert(box.info.ro)" + +for _, server in pairs(SERVERS) do\ +    ok, res = test_run:eval(server, cfg_set_manual)\ +    assert(ok)\ +end + +-- Promote without living leader. +test_run:switch('election_replica1') +assert(box.info.election.state == 'follower') +term = box.info.election.term +box.ctl.promote() +assert(box.info.election.state == 'leader') +assert(not box.info.ro) +assert(box.info.election.term > term) + +-- Test promote when there's a live leader. +test_run:switch('election_replica2') +term = box.info.election.term +assert(box.info.election.state == 'follower') +assert(box.info.ro) +assert(box.info.election.leader ~= 0) +box.ctl.promote() +assert(box.info.election.state == 'leader') +assert(not box.info.ro) +assert(box.info.election.term > term) + +-- Cleanup. +test_run:switch('default') +test_run:drop_cluster(SERVERS) diff --git a/test/replication/suite.cfg b/test/replication/suite.cfg index 0a270d3d6..2fa3c5660 100644 --- a/test/replication/suite.cfg +++ b/test/replication/suite.cfg @@ -2,6 +2,7 @@      "anon.test.lua": {},      "anon_register_gap.test.lua": {},      "gh-2991-misc-asserts-on-update.test.lua": {}, +    "gh-3055-election-promote.test.lua": {},      "gh-3111-misc-rebootstrap-from-ro-master.test.lua": {},      "gh-3160-misc-heartbeats-on-master-changes.test.lua": {},      "gh-3247-misc-iproto-sequence-value-not-replicated.test.lua": {}, -- Serge Petrenko