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 43E566EC40; Mon, 27 Sep 2021 10:13:35 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 43E566EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1632726815; bh=NIK3OuDK/o/YPHO80a63M6ExWR8iBJOjOlho+vorMb0=; 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=fostvSeKfREZXBOqRg+XSIQIk3rieeBrqftt3TS6SCvNiO2sV0JoFVZ1J14qqx5YR sKJeRB6QsPktDs4rKRceXZnWS8CYgVk/iwb7nXGzMkjmgCBsObJMoYugoD/szs644U /bqC3J763M97dDatnWtSnzfY9sdgy7rTr1JinhNo= Received: from smtp61.i.mail.ru (smtp61.i.mail.ru [217.69.128.41]) (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 32EAA6EC40 for ; Mon, 27 Sep 2021 10:13:34 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 32EAA6EC40 Received: by smtp61.i.mail.ru with esmtpa (envelope-from ) id 1mUkpR-0005U7-D9; Mon, 27 Sep 2021 10:13:33 +0300 To: Cyrill Gorcunov , tml Cc: Vladislav Shpilevoy References: <20210922130535.79479-1-gorcunov@gmail.com> <20210922130535.79479-6-gorcunov@gmail.com> Message-ID: <9f449094-3c14-09a6-09a4-56f9163f473f@tarantool.org> Date: Mon, 27 Sep 2021 10:13:32 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20210922130535.79479-6-gorcunov@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: ru X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD96A58C36AA2E996490107B6E0C80113C20C85D07D51133CB8182A05F5380850408CD0C1551208B318DCF1F3CC8AD5375587DAAB1597D62CD1BE151DF934E55746 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE769BF540C95EF782EEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006375B9CF0D2308385458638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8A7733F040B0A316F02A2809EBE71E084117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8BAA867293B0326636D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6BE256E393A9B2437089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A56B89AA1108AC8BF11DC5C082D27FB4A4AB97A5CDBC3B16E3D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75BFC02AB3DF06BA5A410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34047E322BFAFD69BD12E561BC3F1445965B9DE63889BFB9BC2E3C810423AC85EC1245A40AAA121A3B1D7E09C32AA3244C504F1796274C7C18B289977F7D38E25D5595C85A795C7BAEFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojnnOrOlyI/jOG212HdmdOQA== X-Mailru-Sender: 3B9A0136629DC9125D61937A2360A446BE4C767B4EAE22F5F9F39FA28654A4861A3D18CF2C871DDE424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v17 5/5] test: add gh-6036-term-order test 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" 22.09.2021 16:05, Cyrill Gorcunov пишет: > To test that promotion requests are handled only when appropriate > write to WAL completes, because we update memory data before the > write finishes. > > Part-of #6036 > > Signed-off-by: Cyrill Gorcunov > --- > test/replication/gh-6036-order-master.lua | 1 + > test/replication/gh-6036-order-node.lua | 60 ++++++ > test/replication/gh-6036-order-replica1.lua | 1 + > test/replication/gh-6036-order-replica2.lua | 1 + > test/replication/gh-6036-term-order.result | 216 +++++++++++++++++++ > test/replication/gh-6036-term-order.test.lua | 94 ++++++++ > test/replication/suite.cfg | 1 + > test/replication/suite.ini | 2 +- > 8 files changed, 375 insertions(+), 1 deletion(-) > create mode 120000 test/replication/gh-6036-order-master.lua > create mode 100644 test/replication/gh-6036-order-node.lua > create mode 120000 test/replication/gh-6036-order-replica1.lua > create mode 120000 test/replication/gh-6036-order-replica2.lua > create mode 100644 test/replication/gh-6036-term-order.result > create mode 100644 test/replication/gh-6036-term-order.test.lua > > diff --git a/test/replication/gh-6036-order-master.lua b/test/replication/gh-6036-order-master.lua > new file mode 120000 > index 000000000..82a6073a1 > --- /dev/null > +++ b/test/replication/gh-6036-order-master.lua > @@ -0,0 +1 @@ > +gh-6036-order-node.lua > \ No newline at end of file > diff --git a/test/replication/gh-6036-order-node.lua b/test/replication/gh-6036-order-node.lua > new file mode 100644 > index 000000000..b22a7cb4c > --- /dev/null > +++ b/test/replication/gh-6036-order-node.lua > @@ -0,0 +1,60 @@ > +local INSTANCE_ID = string.match(arg[0], "gh%-6036%-order%-(.+)%.lua") > + > +local function unix_socket(name) > + return "unix/:./" .. name .. '.sock'; > +end > + > +require('console').listen(os.getenv('ADMIN')) > + > +if INSTANCE_ID == "master" then > + box.cfg({ > + listen = unix_socket(INSTANCE_ID), > + replication = { > + unix_socket(INSTANCE_ID), > + unix_socket("replica1"), > + unix_socket("replica2"), > + }, > + replication_connect_quorum = 1, > + replication_synchro_quorum = 1, > + replication_synchro_timeout = 10000, > + replication_sync_timeout = 5, > + read_only = false, > + election_mode = "off", > + }) > +elseif INSTANCE_ID == "replica1" then > + box.cfg({ > + listen = unix_socket(INSTANCE_ID), > + replication = { > + unix_socket("master"), > + unix_socket(INSTANCE_ID), > + unix_socket("replica2"), > + }, > + replication_connect_quorum = 1, > + replication_synchro_quorum = 1, > + replication_synchro_timeout = 10000, > + replication_sync_timeout = 5, > + read_only = false, > + election_mode = "off", > + }) > +else > + assert(INSTANCE_ID == "replica2") > + box.cfg({ > + listen = unix_socket(INSTANCE_ID), > + replication = { > + unix_socket("master"), > + unix_socket("replica1"), > + unix_socket(INSTANCE_ID), > + }, > + replication_connect_quorum = 1, > + replication_synchro_quorum = 1, > + replication_synchro_timeout = 10000, > + replication_sync_timeout = 5, > + read_only = true, > + election_mode = "off", > + }) > +end I think it would be simpler to do something like: cfg_tbl = {every common parameter} if INSTANCE_ID == 'replica2' then cfg_tbl.read_only = true box.cfg{} calls for master and replica 1 are identical, replica2 only differs in read_only = true. > + > +--box.ctl.wait_rw() > +box.once("bootstrap", function() > + box.schema.user.grant('guest', 'super') > +end) > diff --git a/test/replication/gh-6036-order-replica1.lua b/test/replication/gh-6036-order-replica1.lua > new file mode 120000 > index 000000000..82a6073a1 > --- /dev/null > +++ b/test/replication/gh-6036-order-replica1.lua > @@ -0,0 +1 @@ > +gh-6036-order-node.lua > \ No newline at end of file > diff --git a/test/replication/gh-6036-order-replica2.lua b/test/replication/gh-6036-order-replica2.lua > new file mode 120000 > index 000000000..82a6073a1 > --- /dev/null > +++ b/test/replication/gh-6036-order-replica2.lua > @@ -0,0 +1 @@ > +gh-6036-order-node.lua > \ No newline at end of file > diff --git a/test/replication/gh-6036-term-order.result b/test/replication/gh-6036-term-order.result > new file mode 100644 > index 000000000..6b19fc2c8 > --- /dev/null > +++ b/test/replication/gh-6036-term-order.result > @@ -0,0 +1,216 @@ > +-- test-run result file version 2 > +-- > +-- gh-6036: verify that terms are locked when we're inside journal > +-- write routine, because parallel appliers may ignore the fact that > +-- the term is updated already but not yet written leading to data > +-- inconsistency. > +-- > +test_run = require('test_run').new() > + | --- > + | ... > + > +test_run:cmd('create server master with script="replication/gh-6036-order-master.lua"') > + | --- > + | - true > + | ... > +test_run:cmd('create server replica1 with script="replication/gh-6036-order-replica1.lua"') > + | --- > + | - true > + | ... > +test_run:cmd('create server replica2 with script="replication/gh-6036-order-replica2.lua"') > + | --- > + | - true > + | ... > + > +test_run:cmd('start server master with wait=False') > + | --- > + | - true > + | ... > +test_run:cmd('start server replica1 with wait=False') > + | --- > + | - true > + | ... > +test_run:cmd('start server replica2 with wait=False') > + | --- > + | - true > + | ... > + > +test_run:wait_fullmesh({"master", "replica1", "replica2"}) > + | --- > + | ... > + > +test_run:switch("master") > + | --- > + | - true > + | ... > +box.ctl.demote() > + | --- > + | ... > + > +test_run:switch("replica1") > + | --- > + | - true > + | ... > +box.ctl.demote() > + | --- > + | ... > + > +test_run:switch("replica2") > + | --- > + | - true > + | ... > +box.ctl.demote() > + | --- > + | ... > + > +-- > +-- Drop connection between master and replica1. > +test_run:switch("master") > + | --- > + | - true > + | ... > +box.cfg({ \ > + replication = { \ > + "unix/:./master.sock", \ > + "unix/:./replica2.sock", \ > + }, \ > +}) > + | --- > + | ... > +test_run:switch("replica1") > + | --- > + | - true > + | ... > +box.cfg({ \ > + replication = { \ > + "unix/:./replica1.sock", \ > + "unix/:./replica2.sock", \ > + }, \ > +}) > + | --- > + | ... > + > +-- > +-- Initiate disk delay and remember the max term seen so far. > +test_run:switch("replica2") > + | --- > + | - true > + | ... > +box.error.injection.set('ERRINJ_WAL_DELAY', true) > + | --- > + | - ok > + | ... > +term_max_replica2 = box.info.synchro.promote.term_max > + | --- > + | ... > + > +-- > +-- Ping-pong the promote action between master and > +-- replica1 nodes, the term updates get queued on > +-- replica2 because of disk being disabled. > +test_run:switch("master") > + | --- > + | - true > + | ... > +box.ctl.promote() > + | --- > + | ... > +box.ctl.demote() > + | --- > + | ... > + > +test_run:switch("replica1") > + | --- > + | - true > + | ... > +box.ctl.promote() > + | --- > + | ... > +box.ctl.demote() > + | --- > + | ... > + > +test_run:switch("master") > + | --- > + | - true > + | ... > +box.ctl.promote() > + | --- > + | ... > + > +-- > +-- Since we're guarding max promote term make sure that > +-- 1) The max term has not yet been updated because WAL > +-- is in sleeping state. > +-- 2) Max term on master and replica1 nodes are greater > +-- than we have now because terms update is locked. > +-- 3) Once WAL is unlocked we make sure that terms has > +-- reached us. > +test_run:switch("replica2") > + | --- > + | - true > + | ... > +assert(term_max_replica2 == box.info.synchro.promote.term_max) > + | --- > + | - true > + | ... > + > +term_max_master = test_run:eval('master', 'box.info.synchro.promote.term_max')[1] > + | --- > + | ... > +term_max_replica1 = test_run:eval('replica1', 'box.info.synchro.promote.term_max')[1] > + | --- > + | ... > +assert(term_max_master > term_max_replica2) > + | --- > + | - true > + | ... > +assert(term_max_replica1 > term_max_replica2) > + | --- > + | - true > + | ... > +term_max_wait4 = term_max_master > + | --- > + | ... > +if term_max_wait4 < term_max_replica1 then term_max_wait4 = term_max_replica1 end > + | --- > + | ... > + > +box.error.injection.set('ERRINJ_WAL_DELAY', false) > + | --- > + | - ok > + | ... > +test_run:wait_cond(function() return box.info.synchro.promote.term_max == term_max_wait4 end) > + | --- > + | - true > + | ... > + > +test_run:switch("default") > + | --- > + | - true > + | ... > +test_run:cmd('stop server master') > + | --- > + | - true > + | ... > +test_run:cmd('stop server replica1') > + | --- > + | - true > + | ... > +test_run:cmd('stop server replica2') > + | --- > + | - true > + | ... > + > +test_run:cmd('delete server master') > + | --- > + | - true > + | ... > +test_run:cmd('delete server replica1') > + | --- > + | - true > + | ... > +test_run:cmd('delete server replica2') > + | --- > + | - true > + | ... > diff --git a/test/replication/gh-6036-term-order.test.lua b/test/replication/gh-6036-term-order.test.lua > new file mode 100644 > index 000000000..01d73ac55 > --- /dev/null > +++ b/test/replication/gh-6036-term-order.test.lua > @@ -0,0 +1,94 @@ > +-- > +-- gh-6036: verify that terms are locked when we're inside journal > +-- write routine, because parallel appliers may ignore the fact that > +-- the term is updated already but not yet written leading to data > +-- inconsistency. > +-- > +test_run = require('test_run').new() > + > +test_run:cmd('create server master with script="replication/gh-6036-order-master.lua"') > +test_run:cmd('create server replica1 with script="replication/gh-6036-order-replica1.lua"') > +test_run:cmd('create server replica2 with script="replication/gh-6036-order-replica2.lua"') > + > +test_run:cmd('start server master with wait=False') > +test_run:cmd('start server replica1 with wait=False') > +test_run:cmd('start server replica2 with wait=False') > + > +test_run:wait_fullmesh({"master", "replica1", "replica2"}) > + > +test_run:switch("master") > +box.ctl.demote() > + > +test_run:switch("replica1") > +box.ctl.demote() > + > +test_run:switch("replica2") > +box.ctl.demote() > + > +-- > +-- Drop connection between master and replica1. > +test_run:switch("master") > +box.cfg({ \ > + replication = { \ > + "unix/:./master.sock", \ > + "unix/:./replica2.sock", \ > + }, \ > +}) > +test_run:switch("replica1") > +box.cfg({ \ > + replication = { \ > + "unix/:./replica1.sock", \ > + "unix/:./replica2.sock", \ > + }, \ > +}) > + > +-- > +-- Initiate disk delay and remember the max term seen so far. > +test_run:switch("replica2") > +box.error.injection.set('ERRINJ_WAL_DELAY', true) > +term_max_replica2 = box.info.synchro.promote.term_max > + > +-- > +-- Ping-pong the promote action between master and > +-- replica1 nodes, the term updates get queued on > +-- replica2 because of disk being disabled. > +test_run:switch("master") > +box.ctl.promote() > +box.ctl.demote() > + > +test_run:switch("replica1") > +box.ctl.promote() > +box.ctl.demote() > + > +test_run:switch("master") > +box.ctl.promote() > + > +-- > +-- Since we're guarding max promote term make sure that > +-- 1) The max term has not yet been updated because WAL > +-- is in sleeping state. > +-- 2) Max term on master and replica1 nodes are greater > +-- than we have now because terms update is locked. > +-- 3) Once WAL is unlocked we make sure that terms has > +-- reached us. > +test_run:switch("replica2") > +assert(term_max_replica2 == box.info.synchro.promote.term_max) > + > +term_max_master = test_run:eval('master', 'box.info.synchro.promote.term_max')[1] > +term_max_replica1 = test_run:eval('replica1', 'box.info.synchro.promote.term_max')[1] > +assert(term_max_master > term_max_replica2) > +assert(term_max_replica1 > term_max_replica2) > +term_max_wait4 = term_max_master > +if term_max_wait4 < term_max_replica1 then term_max_wait4 = term_max_replica1 end > + > +box.error.injection.set('ERRINJ_WAL_DELAY', false) > +test_run:wait_cond(function() return box.info.synchro.promote.term_max == term_max_wait4 end) > + > +test_run:switch("default") > +test_run:cmd('stop server master') > +test_run:cmd('stop server replica1') > +test_run:cmd('stop server replica2') > + > +test_run:cmd('delete server master') > +test_run:cmd('delete server replica1') > +test_run:cmd('delete server replica2') > diff --git a/test/replication/suite.cfg b/test/replication/suite.cfg > index 3eee0803c..ac2bedfd9 100644 > --- a/test/replication/suite.cfg > +++ b/test/replication/suite.cfg > @@ -59,6 +59,7 @@ > "gh-6094-rs-uuid-mismatch.test.lua": {}, > "gh-6127-election-join-new.test.lua": {}, > "gh-6035-applier-filter.test.lua": {}, > + "gh-6036-term-order.test.lua": {}, > "election-candidate-promote.test.lua": {}, > "*": { > "memtx": {"engine": "memtx"}, > diff --git a/test/replication/suite.ini b/test/replication/suite.ini > index 77eb95f49..16840e01f 100644 > --- a/test/replication/suite.ini > +++ b/test/replication/suite.ini > @@ -3,7 +3,7 @@ core = tarantool > script = master.lua > description = tarantool/box, replication > disabled = consistent.test.lua > -release_disabled = catch.test.lua errinj.test.lua gc.test.lua gc_no_space.test.lua before_replace.test.lua qsync_advanced.test.lua qsync_errinj.test.lua quorum.test.lua recover_missing_xlog.test.lua sync.test.lua long_row_timeout.test.lua gh-4739-vclock-assert.test.lua gh-4730-applier-rollback.test.lua gh-5140-qsync-casc-rollback.test.lua gh-5144-qsync-dup-confirm.test.lua gh-5167-qsync-rollback-snap.test.lua gh-5430-qsync-promote-crash.test.lua gh-5430-cluster-mvcc.test.lua gh-5506-election-on-off.test.lua gh-5536-wal-limit.test.lua hang_on_synchro_fail.test.lua anon_register_gap.test.lua gh-5213-qsync-applier-order.test.lua gh-5213-qsync-applier-order-3.test.lua gh-6027-applier-error-show.test.lua gh-6032-promote-wal-write.test.lua gh-6057-qsync-confirm-async-no-wal.test.lua gh-5447-downstream-lag.test.lua gh-4040-invalid-msgpack.test.lua > +release_disabled = catch.test.lua errinj.test.lua gc.test.lua gc_no_space.test.lua before_replace.test.lua qsync_advanced.test.lua qsync_errinj.test.lua quorum.test.lua recover_missing_xlog.test.lua sync.test.lua long_row_timeout.test.lua gh-4739-vclock-assert.test.lua gh-4730-applier-rollback.test.lua gh-5140-qsync-casc-rollback.test.lua gh-5144-qsync-dup-confirm.test.lua gh-5167-qsync-rollback-snap.test.lua gh-5430-qsync-promote-crash.test.lua gh-5430-cluster-mvcc.test.lua gh-5506-election-on-off.test.lua gh-5536-wal-limit.test.lua hang_on_synchro_fail.test.lua anon_register_gap.test.lua gh-5213-qsync-applier-order.test.lua gh-5213-qsync-applier-order-3.test.lua gh-6027-applier-error-show.test.lua gh-6032-promote-wal-write.test.lua gh-6057-qsync-confirm-async-no-wal.test.lua gh-5447-downstream-lag.test.lua gh-4040-invalid-msgpack.test.lua gh-6036-term-order.test.lua > config = suite.cfg > lua_libs = lua/fast_replica.lua lua/rlimit.lua > use_unix_sockets = True -- Serge Petrenko