[Tarantool-patches] [PATCH 1/3 v2] replication: test clear_synchro_queue() function

sergeyb at tarantool.org sergeyb at tarantool.org
Thu Nov 12 12:10:57 MSK 2020


From: Sergey Bronnikov <sergeyb at tarantool.org>

Part of #5055
Part of #4849
---
 test/replication/qsync_basic.result   | 136 ++++++++++++++++++++++++++
 test/replication/qsync_basic.test.lua |  50 ++++++++++
 2 files changed, 186 insertions(+)

diff --git a/test/replication/qsync_basic.result b/test/replication/qsync_basic.result
index bd3c3cce1..e848e305a 100644
--- a/test/replication/qsync_basic.result
+++ b/test/replication/qsync_basic.result
@@ -32,6 +32,13 @@ s2.is_sync
  | - false
  | ...
 
+--
+-- gh-4849: clear synchro queue with unconfigured box
+--
+box.ctl.clear_synchro_queue()
+ | ---
+ | ...
+
 -- Net.box takes sync into account.
 box.schema.user.grant('guest', 'super')
  | ---
@@ -637,6 +644,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()
+ | ---
+ | - running
+ | ...
+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..523dfa779 100644
--- a/test/replication/qsync_basic.test.lua
+++ b/test/replication/qsync_basic.test.lua
@@ -13,6 +13,11 @@ s1:select{}
 s2 = box.schema.create_space('test2')
 s2.is_sync
 
+--
+-- gh-4849: clear synchro queue with unconfigured box
+--
+box.ctl.clear_synchro_queue()
+
 -- Net.box takes sync into account.
 box.schema.user.grant('guest', 'super')
 netbox = require('net.box')
@@ -248,6 +253,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



More information about the Tarantool-patches mailing list