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 4C20F6EC55; Fri, 8 Oct 2021 05:57:58 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4C20F6EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1633661878; bh=13JGwMWNicSxp00Cz7Ep85qrDXvVKZvMT2eRNBp/bsI=; 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=nfVltMP1z7cRWo1dcuLqUTtTeoPW0DO9Fweghfqpm8infQkuVw6x6Tt2Za2J47Y8e UJEBA/Hz/0Q6OhQgP2vKGWeNEJqkoPmr19OueIsKK3jdGGb4hW9m4DiiRyFWQ/1RCj nUWCXSoLYVPaGwrEcQaiY6zPCwarDn+LUsshHEAc= Received: from smtp54.i.mail.ru (smtp54.i.mail.ru [217.69.128.34]) (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 15D4A6EC55 for ; Fri, 8 Oct 2021 05:57:57 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 15D4A6EC55 Received: by smtp54.i.mail.ru with esmtpa (envelope-from ) id 1mYg56-0005hd-8d; Fri, 08 Oct 2021 05:57:56 +0300 To: Cyrill Gorcunov , tml Cc: Vladislav Shpilevoy References: <20211006201522.335898-1-gorcunov@gmail.com> <20211006201522.335898-4-gorcunov@gmail.com> Message-ID: <4d3075ed-48f3-bb14-c302-fbeb9be377f4@tarantool.org> Date: Fri, 8 Oct 2021 05:57:55 +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: <20211006201522.335898-4-gorcunov@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9A6D4E3B1981C4C7DF7D8982532F2974332C9520735F94DDB182A05F538085040E018C3EA6D93D736BA62EF69C740E94002E59DDB5E13F0C174EEEFC4DFC65934 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE79CBBCC7DE3A5D56AEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006377202F6F47B17DBDDEA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BBCA57AF85F7723F2BECF76B8B9F2B09B190C5AC41F79AECECC7F00164DA146DAFE8445B8C89999728AA50765F7900637F6B57BC7E64490618DEB871D839B7333395957E7521B51C2DFABB839C843B9C08941B15DA834481F8AA50765F7900637F3E38EE449E3E2AE389733CBF5DBD5E9B5C8C57E37DE458BD9DD9810294C998ED8FC6C240DEA76428AA50765F7900637F6FE7C89BE6A8FE1D81D268191BDAD3DBD4B6F7A4D31EC0BEA7A3FFF5B025636D81D268191BDAD3D78DA827A17800CE75232FD282772EBEDEC76A7562686271EEC990983EF5C03292E808ACE2090B5E14AD6D5ED66289B5259CC434672EE63711DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C3C9EEE74C166EF7BC35872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458F0AFF96BAACF4158235E5A14AD4A4A4625E192CAD1D9E79D4502FC0A8F8DCC68BE275167CB6ECE4F X-C1DE0DAB: 0D63561A33F958A58FB370E6C08A629C0802C5A86CB31AE6300D67A1DCAAB6B7D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA759D2A03B9C34326B3410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D345DB600F8E858000FA39569FBB0DE84651A42C8EB23EE0B9A7DC7A4CB1C79130815DBADD455BB16B71D7E09C32AA3244C8416672DD75400EDB4EBC9E7E3468E49D9ADFF0C0BDB8D1FFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbhzlKa2eIcWILdregRlQwA== X-Mailru-Sender: 583F1D7ACE8F49BD8518EAAA0E4F94F153D264E3710B99A5099E507E13004E1891431A2EAE3E0579424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v20 3/3] test: add gh-6036-qsync-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" 06.10.2021 23:15, 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. > > Note that without the patch this test fires assertion > >> tarantool: src/box/txn_limbo.c:481: txn_limbo_read_rollback: Assertion `e->txn->signature >= 0' failed. Thanks for the patch! A couple of finalisation comments below. > Part-of #6036 > > Signed-off-by: Cyrill Gorcunov > --- > test/replication/election_replica.lua | 3 +- > test/replication/gh-6036-qsync-order.result | 224 ++++++++++++++++++ > test/replication/gh-6036-qsync-order.test.lua | 103 ++++++++ > test/replication/suite.cfg | 1 + > test/replication/suite.ini | 2 +- > 5 files changed, 331 insertions(+), 2 deletions(-) > create mode 100644 test/replication/gh-6036-qsync-order.result > create mode 100644 test/replication/gh-6036-qsync-order.test.lua > > diff --git a/test/replication/election_replica.lua b/test/replication/election_replica.lua > index 3b4d9a123..1dbfa96dc 100644 > --- a/test/replication/election_replica.lua > +++ b/test/replication/election_replica.lua > @@ -6,6 +6,7 @@ local SYNCHRO_QUORUM = arg[1] and tonumber(arg[1]) or 3 > local ELECTION_TIMEOUT = arg[2] and tonumber(arg[2]) or 0.1 > local ELECTION_MODE = arg[3] or 'candidate' > local CONNECT_QUORUM = arg[4] and tonumber(arg[4]) or 3 > +local SYNCHRO_TIMEOUT = arg[5] and tonumber(arg[5]) or 0.1 > > local function instance_uri(instance_id) > return SOCKET_DIR..'/election_replica'..instance_id..'.sock'; > @@ -25,7 +26,7 @@ box.cfg({ > election_mode = ELECTION_MODE, > election_timeout = ELECTION_TIMEOUT, > replication_synchro_quorum = SYNCHRO_QUORUM, > - replication_synchro_timeout = 0.1, > + replication_synchro_timeout = SYNCHRO_TIMEOUT, Why do you need the synchro_timeout if synchro quorum is 1 anyway? > -- To reveal more election logs. > log_level = 6, > }) > diff --git a/test/replication/gh-6036-qsync-order.result b/test/replication/gh-6036-qsync-order.result > new file mode 100644 > index 000000000..34a7e7803 > --- /dev/null > +++ b/test/replication/gh-6036-qsync-order.result > @@ -0,0 +1,224 @@ > +-- 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/election_replica1.lua"') > + | --- > + | - true > + | ... > +test_run:cmd('create server replica1 with script="replication/election_replica2.lua"') > + | --- > + | - true > + | ... > +test_run:cmd('create server replica2 with script="replication/election_replica3.lua"') > + | --- > + | - true > + | ... > + > +test_run:cmd("start server master with wait=False, args='1 nil manual 1 10000'") > + | --- > + | - true > + | ... > +test_run:cmd("start server replica1 with wait=False, args='1 nil manual 1 10000'") > + | --- > + | - true > + | ... > +test_run:cmd("start server replica2 with wait=False, args='1 nil manual 1 10000'") > + | --- > + | - true > + | ... There's test_run:create_cluster() for all of this. > + > +test_run:wait_fullmesh({"master", "replica1", "replica2"}) > + | --- > + | ... > + > +-- > +-- Create a synchro space on the master node and make > +-- sure the write processed just fine. > +test_run:switch("master") > + | --- > + | - true > + | ... > +box.ctl.promote() > + | --- > + | ... > +s = box.schema.create_space('test', {is_sync = true}) > + | --- > + | ... > +_ = s:create_index('pk') > + | --- > + | ... > +s:insert{1} > + | --- > + | - [1] > + | ... > + > +test_run:switch("replica1") > + | --- > + | - true > + | ... > +test_run:wait_lsn('replica1', 'master') > + | --- > + | ... > + > +test_run:switch("replica2") > + | --- > + | - true > + | ... > +test_run:wait_lsn('replica2', 'master') > + | --- > + | ... > + > +-- > +-- Drop connection between master and replica1. > +test_run:switch("master") > + | --- > + | - true > + | ... > +box.cfg({ \ > + replication = { \ > + "unix/:./election_replica1.sock", \ > + "unix/:./election_replica3.sock", \ > + }, \ > +}) > + | --- > + | ... > +-- > +-- Drop connection between replica1 and master. > +test_run:switch("replica1") > + | --- > + | - true > + | ... > +test_run:wait_cond(function() return box.space.test:get{1} ~= nil end) > + | --- > + | - true > + | ... > +box.cfg({ \ > + replication = { \ > + "unix/:./election_replica2.sock", \ > + "unix/:./election_replica3.sock", \ > + }, \ > +}) > + | --- > + | ... > + > +-- > +-- Here we have the following scheme > +-- > +-- replica2 (will be delayed) > +-- / \ > +-- master replica1 > + > +-- > +-- Initiate disk delay in a bit tricky way: the next write will > +-- fall into forever sleep. > +test_run:switch("replica2") > + | --- > + | - true > + | ... > +box.error.injection.set('ERRINJ_WAL_DELAY_COUNTDOWN', 1) > + | --- > + | - ok ERRINJ_WAL_DELAY_COUNTDOWN only works in conjunction with ERRINJ_WAL_DELAY, so you need to set both. And you should set ERRINJ_WAL_DELAY_COUNTDOWN to 0, otherwise it would let the promote from replica1 through. That's not what we want. By the way, I'd still prefer using ERRINJ_WAL_WRITE_COUNT instead of the countdown, but up to you. > + | ... > +cnt_before = box.error.injection.get('ERRINJ_WAL_DELAY_COUNTDOWN') > + | --- > + | ... > +-- > +-- Make replica1 been a leader and start writting data, > +-- the PROMOTE request get queued on replica2 and not > +-- yet processed, same time INSERT won't complete either > +-- waiting for PROMOTE completion first. Note that we > +-- enter replica2 as well just to be sure the PROMOTE > +-- reached it. > +test_run:switch("replica1") > + | --- > + | - true > + | ... > +box.ctl.promote() > + | --- > + | ... > +test_run:switch("replica2") > + | --- > + | - true > + | ... > +test_run:wait_cond(function() return box.error.injection.get('ERRINJ_WAL_DELAY_COUNTDOWN') < cnt_before end) > + | --- > + | - true > + | ... > +test_run:switch("replica1") > + | --- > + | - true > + | ... > +_ = require('fiber').create(function() box.space.test:insert{2} end) > + | --- > + | ... > + > +-- > +-- The master node has no clue that there is a new leader > +-- and continue writing data with obsolete term. Since replica2 > +-- is delayed now the INSERT won't proceed yet but get queued. > +test_run:switch("master") > + | --- > + | - true > + | ... > +_ = require('fiber').create(function() box.space.test:insert{3} end) > + | --- > + | ... > + > +-- > +-- Finally enable replica2 back. Make sure the data from new replica1 > +-- leader get writing while old leader's data ignored. > +test_run:switch("replica2") > + | --- > + | - true > + | ... > +box.error.injection.set('ERRINJ_WAL_DELAY', false) > + | --- > + | - ok > + | ... > +test_run:wait_cond(function() return box.space.test:get{2} ~= nil end) > + | --- > + | - true > + | ... > +box.space.test:select{} > + | --- > + | - - [1] > + | - [2] > + | ... > + > +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-qsync-order.test.lua b/test/replication/gh-6036-qsync-order.test.lua > new file mode 100644 > index 000000000..47996998d > --- /dev/null > +++ b/test/replication/gh-6036-qsync-order.test.lua > @@ -0,0 +1,103 @@ > +-- > +-- 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/election_replica1.lua"') > +test_run:cmd('create server replica1 with script="replication/election_replica2.lua"') > +test_run:cmd('create server replica2 with script="replication/election_replica3.lua"') > + > +test_run:cmd("start server master with wait=False, args='1 nil manual 1 10000'") > +test_run:cmd("start server replica1 with wait=False, args='1 nil manual 1 10000'") > +test_run:cmd("start server replica2 with wait=False, args='1 nil manual 1 10000'") > + > +test_run:wait_fullmesh({"master", "replica1", "replica2"}) > + > +-- > +-- Create a synchro space on the master node and make > +-- sure the write processed just fine. > +test_run:switch("master") > +box.ctl.promote() > +s = box.schema.create_space('test', {is_sync = true}) > +_ = s:create_index('pk') > +s:insert{1} > + > +test_run:switch("replica1") > +test_run:wait_lsn('replica1', 'master') > + > +test_run:switch("replica2") > +test_run:wait_lsn('replica2', 'master') > + > +-- > +-- Drop connection between master and replica1. > +test_run:switch("master") > +box.cfg({ \ > + replication = { \ > + "unix/:./election_replica1.sock", \ > + "unix/:./election_replica3.sock", \ > + }, \ > +}) > +-- > +-- Drop connection between replica1 and master. > +test_run:switch("replica1") > +test_run:wait_cond(function() return box.space.test:get{1} ~= nil end) > +box.cfg({ \ > + replication = { \ > + "unix/:./election_replica2.sock", \ > + "unix/:./election_replica3.sock", \ > + }, \ > +}) > + > +-- > +-- Here we have the following scheme > +-- > +-- replica2 (will be delayed) > +-- / \ > +-- master replica1 > + > +-- > +-- Initiate disk delay in a bit tricky way: the next write will > +-- fall into forever sleep. > +test_run:switch("replica2") > +box.error.injection.set('ERRINJ_WAL_DELAY_COUNTDOWN', 1) > +cnt_before = box.error.injection.get('ERRINJ_WAL_DELAY_COUNTDOWN') > +-- > +-- Make replica1 been a leader and start writting data, > +-- the PROMOTE request get queued on replica2 and not > +-- yet processed, same time INSERT won't complete either > +-- waiting for PROMOTE completion first. Note that we > +-- enter replica2 as well just to be sure the PROMOTE > +-- reached it. > +test_run:switch("replica1") > +box.ctl.promote() > +test_run:switch("replica2") > +test_run:wait_cond(function() return box.error.injection.get('ERRINJ_WAL_DELAY_COUNTDOWN') < cnt_before end) > +test_run:switch("replica1") > +_ = require('fiber').create(function() box.space.test:insert{2} end) > + > +-- > +-- The master node has no clue that there is a new leader > +-- and continue writing data with obsolete term. Since replica2 > +-- is delayed now the INSERT won't proceed yet but get queued. > +test_run:switch("master") > +_ = require('fiber').create(function() box.space.test:insert{3} end) > + > +-- > +-- Finally enable replica2 back. Make sure the data from new replica1 > +-- leader get writing while old leader's data ignored. > +test_run:switch("replica2") > +box.error.injection.set('ERRINJ_WAL_DELAY', false) > +test_run:wait_cond(function() return box.space.test:get{2} ~= nil end) > +box.space.test:select{} > + > +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..ed09b2087 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-qsync-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..080e4fbf4 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-qsync-order.test.lua > config = suite.cfg > lua_libs = lua/fast_replica.lua lua/rlimit.lua > use_unix_sockets = True -- Serge Petrenko