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 35B576FC87; Fri, 1 Oct 2021 15:30:44 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 35B576FC87 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1633091444; bh=Cs4lki6ZaOJ6nOsbG8iOEPSM/yikkBY+MTrJ77nOQuc=; 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=NQuvYp2OI8f3Snqs2XpT1n14wLHbRjmUhIOJPZNb8w84J7675bodAk6uTKJyTqB4V SDY5VueA3KmWxRvKoqEWWHyJvaVMbjU2dsJb9Pts3oPZW4iVWDyqPoD6FKmxSGs7pq TrAsm9mG6DEgFVIkkFtUSPRI6QgZbgHCTGDFSSno= Received: from smtp59.i.mail.ru (smtp59.i.mail.ru [217.69.128.39]) (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 1E4FB6FC87 for ; Fri, 1 Oct 2021 15:30:43 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1E4FB6FC87 Received: by smtp59.i.mail.ru with esmtpa (envelope-from ) id 1mWHgY-0007f4-9J; Fri, 01 Oct 2021 15:30:42 +0300 To: Cyrill Gorcunov , tml Cc: Vladislav Shpilevoy References: <20210930094445.316694-1-gorcunov@gmail.com> <20210930094445.316694-4-gorcunov@gmail.com> Message-ID: <42713720-689c-221c-29a4-7087ccbc472f@tarantool.org> Date: Fri, 1 Oct 2021 15:30:41 +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: <20210930094445.316694-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: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD96A58C36AA2E996499DED20B83AFF2DE90C450EFC080BE8B7182A05F538085040CBA1A49598F8523BA4E4F38CC57F4DCEEC3B6AD1CFC4DE1E3B2B4F0C98CFE8AB X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE711E5B611353E2625EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063724FB3EE3D47C4C4C8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D897DA2EC15C0416952014405780224E16117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8BAA867293B0326636D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B682BBBAF5DF00056E089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A59329874DC3D86D5AB61826FE0A741A8018240770ABACC6F0D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA757AF5085B7B0228D6410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D345B8C2BEC800D10215EF62B6F0F399E2BF60FAC761EA1C09AADE83B3C6A97CB5416891CF19F8E24F71D7E09C32AA3244C81D55FED8D0C3CB67A6D30AB0AD74D0BB4DF56057A86259FFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojJNmX3owDPmFxa2ccDV/pZw== X-Mailru-Sender: 3B9A0136629DC9125D61937A2360A44627A11426A45E4E579119D007AE283F9BC6D16CAABC9AD7C2424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v19 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" 30.09.2021 12:44, 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 > Thanks for the test! Please, find a couple of comments below. I think the test won't be flaky anymore once you fix my comments. >> tarantool: src/box/txn_limbo.c:481: txn_limbo_read_rollback: Assertion `e->txn->signature >= 0' failed. > Part-of #6036 > > Signed-off-by: Cyrill Gorcunov > --- > test/replication/gh-6036-qsync-master.lua | 1 + > test/replication/gh-6036-qsync-node.lua | 35 +++ > test/replication/gh-6036-qsync-order.result | 207 ++++++++++++++++++ > test/replication/gh-6036-qsync-order.test.lua | 95 ++++++++ > test/replication/gh-6036-qsync-replica1.lua | 1 + > test/replication/gh-6036-qsync-replica2.lua | 1 + > test/replication/suite.cfg | 1 + > test/replication/suite.ini | 2 +- > 8 files changed, 342 insertions(+), 1 deletion(-) > create mode 120000 test/replication/gh-6036-qsync-master.lua > create mode 100644 test/replication/gh-6036-qsync-node.lua > create mode 100644 test/replication/gh-6036-qsync-order.result > create mode 100644 test/replication/gh-6036-qsync-order.test.lua > create mode 120000 test/replication/gh-6036-qsync-replica1.lua > create mode 120000 test/replication/gh-6036-qsync-replica2.lua > > diff --git a/test/replication/gh-6036-qsync-master.lua b/test/replication/gh-6036-qsync-master.lua > new file mode 120000 > index 000000000..87bdb46ef > --- /dev/null > +++ b/test/replication/gh-6036-qsync-master.lua > @@ -0,0 +1 @@ > +gh-6036-qsync-node.lua > \ No newline at end of file > diff --git a/test/replication/gh-6036-qsync-node.lua b/test/replication/gh-6036-qsync-node.lua > new file mode 100644 > index 000000000..ba6213255 > --- /dev/null > +++ b/test/replication/gh-6036-qsync-node.lua > @@ -0,0 +1,35 @@ > +local INSTANCE_ID = string.match(arg[0], "gh%-6036%-qsync%-(.+)%.lua") > + > +local function unix_socket(name) > + return "unix/:./" .. name .. '.sock'; > +end > + > +require('console').listen(os.getenv('ADMIN')) > + > +local box_cfg_common = { > + listen = unix_socket(INSTANCE_ID), > + replication = { > + unix_socket("master"), > + unix_socket("replica1"), > + unix_socket("replica2"), > + }, > + replication_connect_quorum = 1, > + replication_synchro_quorum = 1, > + replication_synchro_timeout = 10000, > +} > + > +if INSTANCE_ID == "master" then > + box_cfg_common['election_mode'] = "manual" > + box.cfg(box_cfg_common) > +elseif INSTANCE_ID == "replica1" then > + box_cfg_common['election_mode'] = "manual" > + box.cfg(box_cfg_common) > +else > + assert(INSTANCE_ID == "replica2") > + box_cfg_common['election_mode'] = "manual" > + box.cfg(box_cfg_common) > +end > + > +box.once("bootstrap", function() > + box.schema.user.grant('guest', 'super') > +end) Looks like "election_replica.lua" suits our needs perfectly now. No need to introduce a new instance file. > diff --git a/test/replication/gh-6036-qsync-order.result b/test/replication/gh-6036-qsync-order.result > new file mode 100644 > index 000000000..378ce917a > --- /dev/null > +++ b/test/replication/gh-6036-qsync-order.result > @@ -0,0 +1,207 @@ > +-- 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-qsync-master.lua"') > + | --- > + | - true > + | ... > +test_run:cmd('create server replica1 with script="replication/gh-6036-qsync-replica1.lua"') > + | --- > + | - true > + | ... > +test_run:cmd('create server replica2 with script="replication/gh-6036-qsync-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"}) > + | --- > + | ... > + > +-- > +-- 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_cond(function() return box.space.test:get{1} ~= nil end) > + | --- > + | - true > + | ... > +test_run:switch("replica2") > + | --- > + | - true > + | ... > +test_run:wait_cond(function() return box.space.test:get{1} ~= nil end) > + | --- > + | - true > + | ... > + You may replace both calls with test_run:wait_lsn('master', 'replica') Even without switching. > +-- > +-- Drop connection between master and replica1. > +test_run:switch("master") > + | --- > + | - true > + | ... > +box.cfg({ \ > + replication = { \ > + "unix/:./master.sock", \ > + "unix/:./replica2.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/:./replica1.sock", \ > + "unix/:./replica2.sock", \ > + }, \ > +}) > + | --- > + | ... > + > +-- > +-- Here we have the following scheme > +-- > +-- replica2 (will be delayed) > +-- / \ > +-- master replica1 > + > +-- > +-- 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 > + | ... > + > +-- > +-- 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. > +test_run:switch("replica1") > + | --- > + | - true > + | ... > +box.ctl.promote() > + | --- > + | ... > +_ = require('fiber').create(function() box.space.test:insert{2} end) > + | --- > + | ... > + > +-- Prior to doing something on master, you should make sure replica2 has received the promote. "wait_lsn" won't work here, because WAL is disabled. You may try test_run:wait_cond(function() return box.space.test:get{2} ~= nil end) > +-- The master node has no clue that there is a new leader > +-- and continue writting 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) > + | --- > + | ... > + Just like above, try to wait until replica2 receives insert{3}. > +-- > +-- Finally enable replica2 back. Make sure the data from new replica1 > +-- leader get writting 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..ac1dc5d91 > --- /dev/null > +++ b/test/replication/gh-6036-qsync-order.test.lua > @@ -0,0 +1,95 @@ > +-- > +-- 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-qsync-master.lua"') > +test_run:cmd('create server replica1 with script="replication/gh-6036-qsync-replica1.lua"') > +test_run:cmd('create server replica2 with script="replication/gh-6036-qsync-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"}) > + > +-- > +-- 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_cond(function() return box.space.test:get{1} ~= nil end) > +test_run:switch("replica2") > +test_run:wait_cond(function() return box.space.test:get{1} ~= nil end) > + > +-- > +-- Drop connection between master and replica1. > +test_run:switch("master") > +box.cfg({ \ > + replication = { \ > + "unix/:./master.sock", \ > + "unix/:./replica2.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/:./replica1.sock", \ > + "unix/:./replica2.sock", \ > + }, \ > +}) > + > +-- > +-- Here we have the following scheme > +-- > +-- replica2 (will be delayed) > +-- / \ > +-- master replica1 > + > +-- > +-- Initiate disk delay and remember the max term seen so far. > +test_run:switch("replica2") > +box.error.injection.set('ERRINJ_WAL_DELAY', true) > + > +-- > +-- 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. > +test_run:switch("replica1") > +box.ctl.promote() > +_ = require('fiber').create(function() box.space.test:insert{2} end) > + > +-- > +-- The master node has no clue that there is a new leader > +-- and continue writting 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 writting 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/gh-6036-qsync-replica1.lua b/test/replication/gh-6036-qsync-replica1.lua > new file mode 120000 > index 000000000..87bdb46ef > --- /dev/null > +++ b/test/replication/gh-6036-qsync-replica1.lua > @@ -0,0 +1 @@ > +gh-6036-qsync-node.lua > \ No newline at end of file > diff --git a/test/replication/gh-6036-qsync-replica2.lua b/test/replication/gh-6036-qsync-replica2.lua > new file mode 120000 > index 000000000..87bdb46ef > --- /dev/null > +++ b/test/replication/gh-6036-qsync-replica2.lua > @@ -0,0 +1 @@ > +gh-6036-qsync-node.lua > \ No newline at end of file > 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