From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp49.i.mail.ru (smtp49.i.mail.ru [94.100.177.109]) (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 CA18B4696C0 for ; Tue, 17 Nov 2020 19:14:22 +0300 (MSK) From: sergeyb@tarantool.org Date: Tue, 17 Nov 2020 19:13:51 +0300 Message-Id: <5ab780fcf5f8c94a6516206a622ed05f4d659894.1605629206.git.sergeyb@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 2/4] replication: test clear_synchro_queue() function List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org From: Sergey Bronnikov Part of #5055 Part of #4849 --- test/replication/qsync_basic.result | 129 ++++++++++++++++++++++++++ test/replication/qsync_basic.test.lua | 45 +++++++++ 2 files changed, 174 insertions(+) diff --git a/test/replication/qsync_basic.result b/test/replication/qsync_basic.result index bd3c3cce1..a06f65ce1 100644 --- a/test/replication/qsync_basic.result +++ b/test/replication/qsync_basic.result @@ -637,6 +637,135 @@ box.space.sync:count() | - 0 | ... +-- +-- gh-4849: clear synchro queue on a master +-- +test_run:switch('default') + | --- + | - true + | ... +box.cfg{replication_synchro_quorum = 3, replication_synchro_timeout = 1000} + | --- + | ... +ok, err = nil + | --- + | ... +f = fiber.create(function() \ + ok, err = pcall(box.space.sync.insert, box.space.sync, {10}) \ +end) + | --- + | ... +f:status() + | --- + | - suspended + | ... +test_run:switch('replica') + | --- + | - true + | ... +test_run:wait_cond(function() return box.space.sync:get{10} ~= nil end) + | --- + | - true + | ... +test_run:switch('default') + | --- + | - true + | ... +box.cfg{replication_synchro_timeout = 0.1} + | --- + | ... +box.ctl.clear_synchro_queue() + | --- + | ... +test_run:switch('replica') + | --- + | - true + | ... +test_run:wait_cond(function() return box.space.sync:get{10} == nil end) + | --- + | - true + | ... +test_run:switch('default') + | --- + | - true + | ... +test_run:wait_cond(function() return f:status() == 'dead' end) + | --- + | - true + | ... +ok, err + | --- + | - false + | - Quorum collection for a synchronous transaction is timed out + | ... +test_run:wait_cond(function() return box.space.sync:get{10} == nil end) + | --- + | - true + | ... + +-- +-- gh-4849: clear synchro queue on a replica, make sure no crashes +-- +test_run:switch('default') + | --- + | - true + | ... +box.cfg{replication_synchro_quorum = 3, replication_synchro_timeout = 1000} + | --- + | ... +ok, err = nil + | --- + | ... +f = fiber.create(function() \ + ok, err = pcall(box.space.sync.insert, box.space.sync, {9}) \ +end) + | --- + | ... +f:status() + | --- + | - suspended + | ... +test_run:wait_cond(function() return box.space.sync:get{9} ~= nil end) + | --- + | - true + | ... +test_run:switch('replica') + | --- + | - true + | ... +box.cfg{replication_synchro_quorum = 3, replication_synchro_timeout=0.01} + | --- + | ... +box.ctl.clear_synchro_queue() + | --- + | ... +test_run:wait_cond(function() return box.space.sync:get{9} == nil end) + | --- + | - true + | ... +test_run:switch('default') + | --- + | - true + | ... +box.cfg{replication_synchro_timeout=0.01} + | --- + | ... +test_run:wait_cond(function() return f:status() == 'dead' end) + | --- + | - true + | ... +ok, err + | --- + | - false + | - Quorum collection for a synchronous transaction is timed out + | ... +test_run:wait_cond(function() return box.space.sync:get{9} == nil end) + | --- + | - true + | ... + +-- Note: cluster may be in a broken state here due to nature of previous test. + -- Cleanup. test_run:cmd('switch default') | --- diff --git a/test/replication/qsync_basic.test.lua b/test/replication/qsync_basic.test.lua index 94235547d..81d3b20ad 100644 --- a/test/replication/qsync_basic.test.lua +++ b/test/replication/qsync_basic.test.lua @@ -248,6 +248,51 @@ for i = 1, 100 do box.space.sync:delete{i} end test_run:cmd('switch replica') box.space.sync:count() +-- +-- gh-4849: clear synchro queue on a master +-- +test_run:switch('default') +box.cfg{replication_synchro_quorum = 3, replication_synchro_timeout = 1000} +ok, err = nil +f = fiber.create(function() \ + ok, err = pcall(box.space.sync.insert, box.space.sync, {10}) \ +end) +f:status() +test_run:switch('replica') +test_run:wait_cond(function() return box.space.sync:get{10} ~= nil end) +test_run:switch('default') +box.cfg{replication_synchro_timeout = 0.1} +box.ctl.clear_synchro_queue() +test_run:switch('replica') +test_run:wait_cond(function() return box.space.sync:get{10} == nil end) +test_run:switch('default') +test_run:wait_cond(function() return f:status() == 'dead' end) +ok, err +test_run:wait_cond(function() return box.space.sync:get{10} == nil end) + +-- +-- gh-4849: clear synchro queue on a replica, make sure no crashes +-- +test_run:switch('default') +box.cfg{replication_synchro_quorum = 3, replication_synchro_timeout = 1000} +ok, err = nil +f = fiber.create(function() \ + ok, err = pcall(box.space.sync.insert, box.space.sync, {9}) \ +end) +f:status() +test_run:wait_cond(function() return box.space.sync:get{9} ~= nil end) +test_run:switch('replica') +box.cfg{replication_synchro_quorum = 3, replication_synchro_timeout=0.01} +box.ctl.clear_synchro_queue() +test_run:wait_cond(function() return box.space.sync:get{9} == nil end) +test_run:switch('default') +box.cfg{replication_synchro_timeout=0.01} +test_run:wait_cond(function() return f:status() == 'dead' end) +ok, err +test_run:wait_cond(function() return box.space.sync:get{9} == nil end) + +-- Note: cluster may be in a broken state here due to nature of previous test. + -- Cleanup. test_run:cmd('switch default') -- 2.25.1