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 AF86C7118D; Mon, 25 Oct 2021 12:52:29 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org AF86C7118D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1635155549; bh=nHhgUTVt9tlQ086cAbpjw531+4jCdzdYD9dX0R2HZiA=; h=To:Cc:Date:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=PsWjHmBBFa6rdLNL+OanYGHnsYt3yIjURrrVN8atSwX7lZzh2/0NShwPFazQuNBCg E1l1SuN4jrWpuJ7CiBxbL/8in47UWvej0W6Y7BhQFdmBnKH+DbV5MLjqq+d69wD+zN BiIEmTTPaaJULpiDlCKAx92w8ldsm5ySrNCDWhNo= Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 6002D7118D for ; Mon, 25 Oct 2021 12:52:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6002D7118D Received: by mail-lj1-f182.google.com with SMTP id n7so8462245ljp.5 for ; Mon, 25 Oct 2021 02:52:28 -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:mime-version :content-transfer-encoding; bh=TYPRqKH7jnmtACRbIGREbi0atKT4EAH40ph8Wwv32Zo=; b=SiXQX/jmR71LWkTZb4u6PDYouCJGgDvY995LSaLFuLaTd8j2gtqYzmy1sXTAaYj0Ye 6desmQY4+az7fKIg0hpZLBe5TqImUsgk/MlYA0XU4M9x274zCRWfJ7TIiilBeQeaWzAb kNLqAFNvPE1DLfdPtRElr+Dpfa1mRf07EUVS+HdYzf1MoaOhcwkHjk9BS45kEIQlOpks ObXjBcMr64pUZjPm5AGuKRPOTNdt7mgiPjWGi1heXm6xe1EC0P4RSXcvgjJ2bQG5lLeI nW4KS8UKPLeVwgQK5nowlEw+fbv+JkB+GciPbdsnqLOsgZCtgK/8qgbyoS2BdUmAR6G4 1cow== X-Gm-Message-State: AOAM5304vQUFlqlwqso8L2NSdYwaymbik3SiNKv+6yU8dApwBjKY8jg7 EMofmZboUDbXdkKzGl6Y0PQJ9PHqW4g= X-Google-Smtp-Source: ABdhPJw1LkwHHt6V/BojJHLmLF2BZjchrpNQMzg/fvPZB9vRwwKiBRu22e6wrV2F6gPYB9U8+4+U/w== X-Received: by 2002:a2e:bc09:: with SMTP id b9mr18706777ljf.110.1635155547508; Mon, 25 Oct 2021 02:52:27 -0700 (PDT) Received: from localhost.localdomain (broadband-46-242-13-228.ip.moscow.rt.ru. [46.242.13.228]) by smtp.gmail.com with ESMTPSA id i13sm1610724lfb.45.2021.10.25.02.52.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Oct 2021 02:52:27 -0700 (PDT) To: tarantool-patches@dev.tarantool.org Cc: Yan Shtunder Date: Mon, 25 Oct 2021 12:52:23 +0300 Message-Id: <20211025095223.22521-1-ya.shtunder@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v3] replication: removing anonymous replicas from synchro quorum 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: Yan Shtunder via Tarantool-patches Reply-To: Yan Shtunder Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Transactions have to committed after they reaches quorum of "real" cluster members. Therefore, anonymous replicas don't have to participate in the quorum. Closes #5418 --- Issue: https://github.com/tarantool/tarantool/issues/5418 Patch: https://github.com/tarantool/tarantool/tree/yshtunder/gh-5418-qsync-with-anon-replicas src/box/relay.cc | 3 +- test/replication-luatest/gh_5418_test.lua | 82 +++++++++++++++++++++++ 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 test/replication-luatest/gh_5418_test.lua diff --git a/src/box/relay.cc b/src/box/relay.cc index f5852df7b..cf569e8e2 100644 --- a/src/box/relay.cc +++ b/src/box/relay.cc @@ -543,6 +543,7 @@ tx_status_update(struct cmsg *msg) struct replication_ack ack; ack.source = status->relay->replica->id; ack.vclock = &status->vclock; + bool anon = status->relay->replica->anon; /* * Let pending synchronous transactions know, which of * them were successfully sent to the replica. Acks are @@ -550,7 +551,7 @@ tx_status_update(struct cmsg *msg) * the single master in 100% so far). Other instances wait * for master's CONFIRM message instead. */ - if (txn_limbo.owner_id == instance_id) { + if (txn_limbo.owner_id == instance_id && !anon) { txn_limbo_ack(&txn_limbo, ack.source, vclock_get(ack.vclock, instance_id)); } diff --git a/test/replication-luatest/gh_5418_test.lua b/test/replication-luatest/gh_5418_test.lua new file mode 100644 index 000000000..265d28ccb --- /dev/null +++ b/test/replication-luatest/gh_5418_test.lua @@ -0,0 +1,82 @@ +local fio = require('fio') +local log = require('log') +local fiber = require('fiber') +local t = require('luatest') +local cluster = require('test.luatest_helpers.cluster') +local helpers = require('test.luatest_helpers.helpers') + +local g = t.group('gh-5418') + +g.before_test('test_qsync_with_anon', function() + g.cluster = cluster:new({}) + + local box_cfg = { + replication = {helpers.instance_uri('master')}, + replication_synchro_quorum = 2, + replication_timeout = 0.1 + } + + g.master = g.cluster:build_server({alias = 'master'}, engine, box_cfg) + + local box_cfg = { + replication = { + helpers.instance_uri('master'), + helpers.instance_uri('replica') + }, + replication_timeout = 0.1, + replication_connect_timeout = 0.5, + read_only = true, + replication_anon = true + } + + g.replica = g.cluster:build_server({alias = 'replica'}, engine, box_cfg) + + g.cluster:join_server(g.master) + g.cluster:join_server(g.replica) + g.cluster:start() + log.info('Everything is started') +end) + +g.after_test('test_qsync_with_anon', function() + g.cluster:stop() + fio.rmtree(g.master.workdir) + fio.rmtree(g.replica.workdir) +end) + +local function wait_vclock(timeout) + local started_at = fiber.clock() + local lsn = g.master:eval("return box.info.vclock[1]") + + local _, tbl = g.master:eval("return next(box.info.replication_anon())") + local to_lsn = tbl.downstream.vclock[1] + + while to_lsn == nil or to_lsn < lsn do + fiber.sleep(0.001) + + if (fiber.clock() - started_at) > timeout then + return false + end + + _, tbl = g.master:eval("return next(box.info.replication_anon())") + to_lsn = tbl.downstream.vclock[1] + + log.info(string.format("master lsn: %d; replica_anon lsn: %d", + lsn, to_lsn)) + end + + return true +end + +g.test_qsync_with_anon = function() + g.master:eval("box.schema.space.create('sync', {is_sync = true})") + g.master:eval("box.space.sync:create_index('pk')") + + t.assert_error_msg_content_equals("Quorum collection for a synchronous transaction is timed out", + function() g.master:eval("return box.space.sync:insert{1}") end) + + -- Wait until everything is replicated from the master to the replica + t.assert(wait_vclock(1)) + + t.assert_equals(g.master:eval("return box.space.sync:select()"), {}) + t.assert_equals(g.replica:eval("return box.space.sync:select()"), {}) +end -- 2.25.1