From: Serge Petrenko via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: v.shpilevoy@tarantool.org, gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH 9/9] box.ctl: rename clear_synchro_queue to promote Date: Mon, 12 Apr 2021 22:24:57 +0300 [thread overview] Message-ID: <045f1540-c418-b5c4-322b-79351e1e724c@tarantool.org> (raw) In-Reply-To: <aaafb207b342098240a6c193f9154e20dc78aed7.1618163409.git.sergepetrenko@tarantool.org> 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
prev parent reply other threads:[~2021-04-12 19:25 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-04-11 17:55 [Tarantool-patches] [PATCH 0/9] raft: introduce manual elections and fix a bug with re-applying rolled back transactions Serge Petrenko via Tarantool-patches 2021-04-11 17:55 ` [Tarantool-patches] [PATCH 1/9] wal: enrich row's meta information with sync replication flags Serge Petrenko via Tarantool-patches 2021-04-12 13:06 ` Cyrill Gorcunov via Tarantool-patches 2021-04-13 13:26 ` Serge Petrenko via Tarantool-patches 2021-04-12 19:21 ` Serge Petrenko via Tarantool-patches 2021-04-11 17:55 ` [Tarantool-patches] [PATCH 2/9] xrow: introduce a PROMOTE entry Serge Petrenko via Tarantool-patches 2021-04-11 17:55 ` [Tarantool-patches] [PATCH 3/9] box: actualise iproto_key_type array Serge Petrenko via Tarantool-patches 2021-04-11 17:55 ` [Tarantool-patches] [PATCH 4/9] box: make clear_synchro_queue() write a PROMOTE entry instead of CONFIRM + ROLLBACK Serge Petrenko via Tarantool-patches 2021-04-11 17:56 ` [Tarantool-patches] [PATCH 5/9] box: write PROMOTE even for empty limbo Serge Petrenko via Tarantool-patches 2021-04-11 17:56 ` [Tarantool-patches] [PATCH 6/9] raft: keep track of greatest known term and filter replication sources based on that Serge Petrenko via Tarantool-patches 2021-04-12 19:23 ` Serge Petrenko via Tarantool-patches 2021-04-11 17:56 ` [Tarantool-patches] [PATCH 7/9] replication: introduce a new election mode: "manual" Serge Petrenko via Tarantool-patches 2021-04-11 17:56 ` [Tarantool-patches] [PATCH 8/9] Support manual elections in `box.ctl.clear_synchro_queue()` Serge Petrenko via Tarantool-patches 2021-04-12 19:23 ` Serge Petrenko via Tarantool-patches 2021-04-11 17:56 ` [Tarantool-patches] [PATCH 9/9] box.ctl: rename clear_synchro_queue to promote Serge Petrenko via Tarantool-patches 2021-04-12 19:24 ` Serge Petrenko via Tarantool-patches [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=045f1540-c418-b5c4-322b-79351e1e724c@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=gorcunov@gmail.com \ --cc=sergepetrenko@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 9/9] box.ctl: rename clear_synchro_queue to promote' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox