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 4F02B6EC56; Thu, 18 Mar 2021 21:42:43 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4F02B6EC56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1616092963; bh=ALAyGYVEllDYo3MQ0VaT+sSLPhzJCoRnIUiAvAOTTAI=; 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=Rzsd2K+bUb1lq3eIToi8PTql6DfKmAMt+7yTfenDg1wFPoHcqmSk+clA9S5tHIlG+ j6XQ1UqaWoLmYTI4pCjpELHljaQeYk9YbBNB2gPch751oAFHF+vp2lYhPgTJdj2snF A8S5tG+/oqIRbdmgu6Bo3Po8hcE3Qn5oewJ9lhG8= Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (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 45E326EC5A for ; Thu, 18 Mar 2021 21:42:06 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 45E326EC5A Received: by mail-lj1-f169.google.com with SMTP id a1so8818283ljp.2 for ; Thu, 18 Mar 2021 11:42:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yZRRT3ipmDB9qxOG1kWVoni9kRBLr24r+NmXQwKZftY=; b=a11tfNdWzvhQG4QPlFu0sTFcpmG/9166E3phHJ5KrFZibsTL3Pl6iTnz4mIUDx0wWX nMYO8XPP+zdLaATYbHH22H24if12h1hYiKtQyhLS973GxJBs73vEoE15YdLWCk5CRIOt SsPmc6R2fuheYGMnD18jT5lCZnCvG1eHfTwvugfHIOetVdoc15BdNHeNm17ZYvwRcuFG LJEzRM6P3rK1b8pYwajUV22UHmrfOsmoBOsYII6ryWttPVNRCshwByGS+mszY1bRZl/Z KkgGTvVsF47R0dN22AtmIZsU8XZemDlk0g6GqbLclJb1gL7UmXwLzbaYrQhVzZApcvTw oMKA== X-Gm-Message-State: AOAM531JtG2CSzgGTQig8cp37z8E+1Sw51/+X8kRy4fBjg4S3Bf6L+N/ X3oXe6SK/6JEGDDMGCm/0nQ= X-Google-Smtp-Source: ABdhPJymlhhvfUY1cPh23qGvWjQ7aA+vFUQlJzQrMScgFaEJKa4dj2HGR2/cF5fbJYVH/X+YGS+hnA== X-Received: by 2002:a2e:8599:: with SMTP id b25mr6076599lji.98.1616092925768; Thu, 18 Mar 2021 11:42:05 -0700 (PDT) Received: from grain.localdomain ([5.18.171.94]) by smtp.gmail.com with ESMTPSA id u16sm323663lff.169.2021.03.18.11.42.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 11:42:04 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id D17DD56012D; Thu, 18 Mar 2021 21:41:39 +0300 (MSK) To: tml Date: Thu, 18 Mar 2021 21:41:38 +0300 Message-Id: <20210318184138.1077807-3-gorcunov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210318184138.1077807-1-gorcunov@gmail.com> References: <20210318184138.1077807-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 2/2] test: add a test for wal_cleanup_delay option 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 , Mons Anderson Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Part-of #5806 Signed-off-by: Cyrill Gorcunov --- test/replication/gh-5806-master.lua | 13 + test/replication/gh-5806-slave.lua | 13 + test/replication/gh-5806-xlog-cleanup.result | 336 ++++++++++++++++++ .../replication/gh-5806-xlog-cleanup.test.lua | 148 ++++++++ 4 files changed, 510 insertions(+) create mode 100644 test/replication/gh-5806-master.lua create mode 100644 test/replication/gh-5806-slave.lua create mode 100644 test/replication/gh-5806-xlog-cleanup.result create mode 100644 test/replication/gh-5806-xlog-cleanup.test.lua diff --git a/test/replication/gh-5806-master.lua b/test/replication/gh-5806-master.lua new file mode 100644 index 000000000..0404965d3 --- /dev/null +++ b/test/replication/gh-5806-master.lua @@ -0,0 +1,13 @@ +#!/usr/bin/env tarantool + +require('console').listen(os.getenv('ADMIN')) + +function func_xlog_snap(space, value) + space:insert(value) + box.snapshot() +end + +box.cfg({ + listen = os.getenv("LISTEN"), + wal_cleanup_delay = tonumber(arg[1]) or 0, +}) diff --git a/test/replication/gh-5806-slave.lua b/test/replication/gh-5806-slave.lua new file mode 100644 index 000000000..917dbb1ae --- /dev/null +++ b/test/replication/gh-5806-slave.lua @@ -0,0 +1,13 @@ +#!/usr/bin/env tarantool + +require('console').listen(os.getenv('ADMIN')) + +function func_xlog_snap(space, value) + space:insert(value) + box.snapshot() +end + +box.cfg({ + listen = os.getenv("LISTEN"), + replication = os.getenv("MASTER"), +}) diff --git a/test/replication/gh-5806-xlog-cleanup.result b/test/replication/gh-5806-xlog-cleanup.result new file mode 100644 index 000000000..97355a8bf --- /dev/null +++ b/test/replication/gh-5806-xlog-cleanup.result @@ -0,0 +1,336 @@ +-- test-run result file version 2 +-- +-- gh-5806: defer xlog cleanup to keep xlogs until +-- replicas present in "_cluster" are connected. +-- Otherwise we are getting XlogGapError since +-- master might go far forwad from replica and +-- replica won't be able to connect without full +-- rebootstrap. +-- + +fiber = require('fiber') + | --- + | ... +test_run = require('test_run').new() + | --- + | ... +engine = test_run:get_cfg('engine') + | --- + | ... + +-- +-- Case 1. +-- +-- First lets make sure we're getting XlogGapError in +-- case if wal_cleanup_delay is not used. +-- + +test_run:cmd('create server master with script="replication/gh-5806-master.lua"') + | --- + | - true + | ... +test_run:cmd('start server master with wait=True, wait_load=True') + | --- + | - true + | ... + +test_run:switch('master') + | --- + | - true + | ... +box.schema.user.grant('guest', 'replication') + | --- + | ... + +-- +-- Keep small number of snaps to force cleanup +-- procedure be more intensive. +box.cfg{checkpoint_count = 1} + | --- + | ... + +engine = test_run:get_cfg('engine') + | --- + | ... +s = box.schema.space.create('test', {engine = engine}) + | --- + | ... +_ = s:create_index('pk') + | --- + | ... + +test_run:switch('default') + | --- + | - true + | ... +test_run:cmd('create server replica with rpl_master=master,\ + script="replication/gh-5806-slave.lua"') + | --- + | - true + | ... +test_run:cmd('start server replica with wait=True, wait_load=True') + | --- + | - true + | ... + +test_run:switch('replica') + | --- + | - true + | ... +box.cfg{checkpoint_count = 1} + | --- + | ... +s = box.schema.space.create('testtemp', {temporary = true}) + | --- + | ... +_ = s:create_index('pk') + | --- + | ... +for i=1,2 do func_xlog_snap(box.space.testtemp, {i}) end + | --- + | ... + +-- +-- Stop the replica node and generate +-- first range of xlogs on the master. +test_run:switch('default') + | --- + | - true + | ... +test_run:cmd('stop server replica') + | --- + | - true + | ... + +test_run:switch('master') + | --- + | - true + | ... +for i=1,2 do func_xlog_snap(box.space.test, {i}) end + | --- + | ... + +-- +-- Restart the masted and generate the +-- next range of xlogs. +test_run:switch('default') + | --- + | - true + | ... +test_run:cmd('stop server master') + | --- + | - true + | ... +test_run:cmd('start server master with wait_load=True') + | --- + | - true + | ... +test_run:switch('master') + | --- + | - true + | ... +for i=3,4 do func_xlog_snap(box.space.test, {i}) end + | --- + | ... + +-- +-- Restart master node and the replica then. +test_run:switch('default') + | --- + | - true + | ... +test_run:cmd('stop server master') + | --- + | - true + | ... +test_run:cmd('start server master with wait_load=True') + | --- + | - true + | ... +test_run:cmd('start server replica with wait=False, wait_load=False') + | --- + | - true + | ... + +-- +-- Wait error to appear. +while test_run:grep_log("master", "XlogGapError") == nil do fiber.sleep(0.01) end + | --- + | ... + +-- +-- Cleanup. +test_run:cmd('stop server master') + | --- + | - true + | ... +test_run:cmd('stop server replica') + | --- + | - true + | ... +test_run:cmd('delete server master') + | --- + | - true + | ... +test_run:cmd('delete server replica') + | --- + | - true + | ... + +-- +-- Case 2. +-- +-- Lets make sure we're not getting XlogGapError in +-- case if wal_cleanup_delay is used. +-- + +test_run:cmd('create server master with script="replication/gh-5806-master.lua"') + | --- + | - true + | ... +test_run:cmd('start server master with args="3600", wait=True, wait_load=True') + | --- + | - true + | ... + +test_run:switch('master') + | --- + | - true + | ... +box.schema.user.grant('guest', 'replication') + | --- + | ... + +-- +-- Keep small number of snaps to force cleanup +-- procedure be more intensive. +box.cfg{checkpoint_count = 1} + | --- + | ... + +engine = test_run:get_cfg('engine') + | --- + | ... +s = box.schema.space.create('test', {engine = engine}) + | --- + | ... +_ = s:create_index('pk') + | --- + | ... + +test_run:switch('default') + | --- + | - true + | ... +test_run:cmd('create server replica with rpl_master=master,\ + script="replication/gh-5806-slave.lua"') + | --- + | - true + | ... +test_run:cmd('start server replica with wait=True, wait_load=True') + | --- + | - true + | ... + +test_run:switch('replica') + | --- + | - true + | ... +box.cfg{checkpoint_count = 1} + | --- + | ... +s = box.schema.space.create('testtemp', {temporary = true}) + | --- + | ... +_ = s:create_index('pk') + | --- + | ... +for i=1,2 do func_xlog_snap(box.space.testtemp, {i}) end + | --- + | ... + +-- +-- Stop the replica node and generate +-- first range of xlogs on the master. +test_run:switch('default') + | --- + | - true + | ... +test_run:cmd('stop server replica') + | --- + | - true + | ... + +test_run:switch('master') + | --- + | - true + | ... +for i=1,2 do func_xlog_snap(box.space.test, {i}) end + | --- + | ... + +-- +-- Restart the masted and generate the +-- next range of xlogs. +test_run:switch('default') + | --- + | - true + | ... +test_run:cmd('stop server master') + | --- + | - true + | ... +test_run:cmd('start server master with args="3600", wait=True, wait_load=True') + | --- + | - true + | ... +test_run:switch('master') + | --- + | - true + | ... +for i=3,4 do func_xlog_snap(box.space.test, {i}) end + | --- + | ... + +-- +-- Restart master node and the replica then. +test_run:switch('default') + | --- + | - true + | ... +test_run:cmd('stop server master') + | --- + | - true + | ... +test_run:cmd('start server master with args="3600", wait=True, wait_load=True') + | --- + | - true + | ... +test_run:cmd('start server replica with wait=True, wait_load=True') + | --- + | - true + | ... + +assert(test_run:grep_log("master", "XlogGapError") == nil) + | --- + | - true + | ... + +-- +-- Cleanup. +test_run:cmd('stop server master') + | --- + | - true + | ... +test_run:cmd('stop server replica') + | --- + | - true + | ... +test_run:cmd('delete server master') + | --- + | - true + | ... +test_run:cmd('delete server replica') + | --- + | - true + | ... diff --git a/test/replication/gh-5806-xlog-cleanup.test.lua b/test/replication/gh-5806-xlog-cleanup.test.lua new file mode 100644 index 000000000..6232e3964 --- /dev/null +++ b/test/replication/gh-5806-xlog-cleanup.test.lua @@ -0,0 +1,148 @@ +-- +-- gh-5806: defer xlog cleanup to keep xlogs until +-- replicas present in "_cluster" are connected. +-- Otherwise we are getting XlogGapError since +-- master might go far forwad from replica and +-- replica won't be able to connect without full +-- rebootstrap. +-- + +fiber = require('fiber') +test_run = require('test_run').new() +engine = test_run:get_cfg('engine') + +-- +-- Case 1. +-- +-- First lets make sure we're getting XlogGapError in +-- case if wal_cleanup_delay is not used. +-- + +test_run:cmd('create server master with script="replication/gh-5806-master.lua"') +test_run:cmd('start server master with wait=True, wait_load=True') + +test_run:switch('master') +box.schema.user.grant('guest', 'replication') + +-- +-- Keep small number of snaps to force cleanup +-- procedure be more intensive. +box.cfg{checkpoint_count = 1} + +engine = test_run:get_cfg('engine') +s = box.schema.space.create('test', {engine = engine}) +_ = s:create_index('pk') + +test_run:switch('default') +test_run:cmd('create server replica with rpl_master=master,\ + script="replication/gh-5806-slave.lua"') +test_run:cmd('start server replica with wait=True, wait_load=True') + +test_run:switch('replica') +box.cfg{checkpoint_count = 1} +s = box.schema.space.create('testtemp', {temporary = true}) +_ = s:create_index('pk') +for i=1,2 do func_xlog_snap(box.space.testtemp, {i}) end + +-- +-- Stop the replica node and generate +-- first range of xlogs on the master. +test_run:switch('default') +test_run:cmd('stop server replica') + +test_run:switch('master') +for i=1,2 do func_xlog_snap(box.space.test, {i}) end + +-- +-- Restart the masted and generate the +-- next range of xlogs. +test_run:switch('default') +test_run:cmd('stop server master') +test_run:cmd('start server master with wait_load=True') +test_run:switch('master') +for i=3,4 do func_xlog_snap(box.space.test, {i}) end + +-- +-- Restart master node and the replica then. +test_run:switch('default') +test_run:cmd('stop server master') +test_run:cmd('start server master with wait_load=True') +test_run:cmd('start server replica with wait=False, wait_load=False') + +-- +-- Wait error to appear. +while test_run:grep_log("master", "XlogGapError") == nil do fiber.sleep(0.01) end + +-- +-- Cleanup. +test_run:cmd('stop server master') +test_run:cmd('stop server replica') +test_run:cmd('delete server master') +test_run:cmd('delete server replica') + +-- +-- Case 2. +-- +-- Lets make sure we're not getting XlogGapError in +-- case if wal_cleanup_delay is used. +-- + +test_run:cmd('create server master with script="replication/gh-5806-master.lua"') +test_run:cmd('start server master with args="3600", wait=True, wait_load=True') + +test_run:switch('master') +box.schema.user.grant('guest', 'replication') + +-- +-- Keep small number of snaps to force cleanup +-- procedure be more intensive. +box.cfg{checkpoint_count = 1} + +engine = test_run:get_cfg('engine') +s = box.schema.space.create('test', {engine = engine}) +_ = s:create_index('pk') + +test_run:switch('default') +test_run:cmd('create server replica with rpl_master=master,\ + script="replication/gh-5806-slave.lua"') +test_run:cmd('start server replica with wait=True, wait_load=True') + +test_run:switch('replica') +box.cfg{checkpoint_count = 1} +s = box.schema.space.create('testtemp', {temporary = true}) +_ = s:create_index('pk') +for i=1,2 do func_xlog_snap(box.space.testtemp, {i}) end + +-- +-- Stop the replica node and generate +-- first range of xlogs on the master. +test_run:switch('default') +test_run:cmd('stop server replica') + +test_run:switch('master') +for i=1,2 do func_xlog_snap(box.space.test, {i}) end + +-- +-- Restart the masted and generate the +-- next range of xlogs. +test_run:switch('default') +test_run:cmd('stop server master') +test_run:cmd('start server master with args="3600", wait=True, wait_load=True') +test_run:switch('master') +for i=3,4 do func_xlog_snap(box.space.test, {i}) end + +-- +-- Restart master node and the replica then. +test_run:switch('default') +test_run:cmd('stop server master') +test_run:cmd('start server master with args="3600", wait=True, wait_load=True') +test_run:cmd('start server replica with wait=True, wait_load=True') + +assert(test_run:grep_log("master", "XlogGapError") == nil) + +-- +-- Cleanup. +test_run:cmd('stop server master') +test_run:cmd('stop server replica') +test_run:cmd('delete server master') +test_run:cmd('delete server replica') -- 2.30.2