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 DF3086EC40; Mon, 20 Sep 2021 18:24:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org DF3086EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1632151465; bh=kgn7dcMK+d7+J4iFAnpPz+n5MokVfHdGuH03acrabek=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Tiuscvyt3HLq0YFUky2hhM/qANFPL9WYrvQBmQB5P8T+pW4GZdge1TqwRonUlTix3 5hpK3rEmIomCjh0KdxzWg8fqzFRJPDz/rmfAwLjRqbBnPbuS+xv+70T+cJRcbU/pzP qghXDvafhvp3Y4v9y8huKF6zy2V4RIhZxxxgTZx4= Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id F18E46EC40 for ; Mon, 20 Sep 2021 18:24:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F18E46EC40 Received: by mail-lf1-f48.google.com with SMTP id i4so69740327lfv.4 for ; Mon, 20 Sep 2021 08:24:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xl3JvniOqiDB5yT1mJUgs8KC78ftAugm25nPZ/iI0pU=; b=ANYjnV0t1cNL06I7J5+CW5pt3dIGr3DsQeH3k32lmGeW6FyopcOfIRd5vXT8ywjzN3 /jOc8SQT0iJHUd6tTtzq/tIzP6SHK/IrGpBNeHLABIJAnZjD+LMMvoSkUZAy86mHZ1Ai xhzsV6xxImgjfVimEDn06zGNg3rhB1nz31k4VzsCn0gm2FFZL1nlbYHhb/U+oONDOm2A zorrohYAkGZcGi9UmVK1U/tOAo7o39UdoWjXMzPWrdvKISt5ryZSqkG1SQhf4B5SbAwp SkV6CPzT6jxPeEvLEPK86CL34071KKjVVnSEnuTfmAe/NYNg51FpKqPmgje7a9pqBlgo 1vcQ== X-Gm-Message-State: AOAM533+VWsggZhaJrVeBSgMb2/Y+6Dm8YAcJk3sYNPCcWQJifvAThs3 ciMc1/3za27BL9LQO4DSTOHRa4wK6hA= X-Google-Smtp-Source: ABdhPJw1/CrdGIA8M8STykQd9aGyOXD8GIQg+nxWFmQzzSf4Fv1/G7TWszuV+lFsjMN7ac0uWuKcMg== X-Received: by 2002:ac2:5f41:: with SMTP id 1mr8217873lfz.79.1632151373236; Mon, 20 Sep 2021 08:22:53 -0700 (PDT) Received: from grain.localdomain ([5.18.253.97]) by smtp.gmail.com with ESMTPSA id t22sm1401463lfd.170.2021.09.20.08.22.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Sep 2021 08:22:52 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id 82A505A001E; Mon, 20 Sep 2021 18:22:51 +0300 (MSK) To: tml Date: Mon, 20 Sep 2021 18:22:48 +0300 Message-Id: <20210920152248.321364-1-gorcunov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210915145046.133303-1-gorcunov@gmail.com> References: <20210915145046.133303-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 4/3] 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: Cyrill Gorcunov via Tarantool-patches Reply-To: Cyrill Gorcunov Cc: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" In-scope-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 | 222 +++++++++++++++++++ test/replication/gh-6036-term-order.test.lua | 89 ++++++++ test/replication/suite.cfg | 1 + 7 files changed, 375 insertions(+) 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 + +--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..3a5f8bfb2 --- /dev/null +++ b/test/replication/gh-6036-term-order.result @@ -0,0 +1,222 @@ +-- 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() + | --- + | ... +assert(box.info.election.term == 1) + | --- + | - true + | ... + +test_run:switch("replica1") + | --- + | - true + | ... +box.ctl.demote() + | --- + | ... +assert(box.info.election.term == 1) + | --- + | - true + | ... + +test_run:switch("replica2") + | --- + | - true + | ... +box.ctl.demote() + | --- + | ... +assert(box.info.election.term == 1) + | --- + | - true + | ... + +-- +-- 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 on replica2 +test_run:switch("replica2") + | --- + | - true + | ... +assert(box.info.election.term == 1) + | --- + | - true + | ... +box.error.injection.set('ERRINJ_WAL_DELAY', true) + | --- + | - ok + | ... + +-- +-- 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() + | --- + | ... +assert(box.info.election.term == 2) + | --- + | - true + | ... +box.ctl.demote() + | --- + | ... +assert(box.info.election.term == 3) + | --- + | - true + | ... + +test_run:switch("replica1") + | --- + | - true + | ... +box.ctl.promote() + | --- + | ... +assert(box.info.election.term == 2) + | --- + | - true + | ... +box.ctl.demote() + | --- + | ... +assert(box.info.election.term == 3) + | --- + | - true + | ... + +test_run:switch("master") + | --- + | - true + | ... +box.ctl.promote() + | --- + | ... +assert(box.info.election.term == 4) + | --- + | - true + | ... + +-- +-- Finally turn back disk on replica2 so the +-- terms get sequenced. +test_run:switch("replica2") + | --- + | - true + | ... +assert(box.info.election.term == 2) + | --- + | - true + | ... +box.error.injection.set('ERRINJ_WAL_DELAY', false) + | --- + | - ok + | ... +test_run:wait_cond(function() return box.info.election.term == 4 end, 100) + | --- + | - 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..79dd8efe4 --- /dev/null +++ b/test/replication/gh-6036-term-order.test.lua @@ -0,0 +1,89 @@ +-- +-- 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() +assert(box.info.election.term == 1) + +test_run:switch("replica1") +box.ctl.demote() +assert(box.info.election.term == 1) + +test_run:switch("replica2") +box.ctl.demote() +assert(box.info.election.term == 1) + +-- +-- 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 on replica2 +test_run:switch("replica2") +assert(box.info.election.term == 1) +box.error.injection.set('ERRINJ_WAL_DELAY', true) + +-- +-- 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() +assert(box.info.election.term == 2) +box.ctl.demote() +assert(box.info.election.term == 3) + +test_run:switch("replica1") +box.ctl.promote() +assert(box.info.election.term == 2) +box.ctl.demote() +assert(box.info.election.term == 3) + +test_run:switch("master") +box.ctl.promote() +assert(box.info.election.term == 4) + +-- +-- Finally turn back disk on replica2 so the +-- terms get sequenced. +test_run:switch("replica2") +assert(box.info.election.term == 2) +box.error.injection.set('ERRINJ_WAL_DELAY', false) +test_run:wait_cond(function() return box.info.election.term == 4 end, 100) + +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"}, -- 2.31.1