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 7878A70361; Wed, 10 Feb 2021 02:47:50 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7878A70361 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1612914470; bh=uOPILS/SD8M3jSjy9jyZ53o20IzpflHUj3w7pFY1gQ8=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=pJit/GO9upuIe91ZhPWcGA/1u3JPn8aHzxX66OsM6uuRsNufZn6+VHtOPszYQVQAA 4edM/fyWGktaTKpvGrIC2ovoxCnhvHstymnaFhs6a/ByDiFK07XT6cl20AZTMKrdR6 iVqwdK4AxiRLCH8WwbobZ+23hxXgP5gvguxUu5G8= Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (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 0ABE670361 for ; Wed, 10 Feb 2021 02:46:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0ABE670361 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1l9ci2-0002gH-Rk; Wed, 10 Feb 2021 02:46:19 +0300 To: tarantool-patches@dev.tarantool.org, olegrok@tarantool.org, yaroslav.dynnikov@tarantool.org Date: Wed, 10 Feb 2021 00:46:09 +0100 Message-Id: X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD953AC099BC0052A9C55152E5B36F7009490E3DBC75EBFD4CE182A05F538085040CE5D8902E37E7F3E0B0CCA1DCFCADFDFFCF95E15F6EBC3946C41121192B2EB76 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE722087ABFAC96EBFEEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063745B6F93C788775E78638F802B75D45FF5571747095F342E8C7A0BC55FA0FE5FCA6073DB25481D6C57B179CDC458B6A18140142178B00F97C389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C07E7E81EEA8A9722B8941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B68424CA1AAF98A6958941B15DA834481F9449624AB7ADAF3735872C767BF85DA29E625A9149C048EE0A3850AC1BE2E73525A4AB119743A3B34AD6D5ED66289B524E70A05D1297E1BB35872C767BF85DA227C277FBC8AE2E8BEBEE3B39F980227375ECD9A6C639B01B4E70A05D1297E1BBC6867C52282FAC85D9B7C4F32B44FF57E8FBB06288C1946000306258E7E6ABB4E4A6367B16DE6309 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CFE63F531D4BE5B7167EDD7C522DEEE2CFA4CCE3EBADB92519C2B6934AE262D3EE7EAB7254005DCED114C52B35DBB74F4E7EAB7254005DCEDA5DF9383870C0FED1E0A4E2319210D9B64D260DF9561598F01A9E91200F654B047F3662BFF48AA648E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34B3611847B8BC2D0B9FB0A6DE91EF705F546C5FA996E28537EED49E914919C0DB339A08D1D1987F291D7E09C32AA3244CABD7A1E8268AE95D150F8A9CACC0E893259227199D06760AFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojmMmQ+JvDeDFixcTA+K7g6g== X-Mailru-Sender: 689FA8AB762F73936BC43F508A0638224BB39DA1B78E45A384605B5225D17F013841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH 3/9] test: introduce a helper to wait for bucket GC 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: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" In the tests to wait for bucket deletion by GC it was necessary to have a long loop expression which checks _bucket space and wakes up GC fiber if the bucket is not deleted yet. Soon the GC wakeup won't be necessary as GC algorithm will become reactive instead of proactive. In order not to remove the wakeup from all places in the main patch, and to simplify the waiting the patch introduces a function wait_bucket_is_collected(). The reactive GC will delete GC wakeup from this function and all the tests still will pass in time. --- test/lua_libs/storage_template.lua | 10 ++++++++++ test/rebalancer/bucket_ref.result | 7 ++----- test/rebalancer/bucket_ref.test.lua | 5 ++--- test/rebalancer/errinj.result | 13 +++++-------- test/rebalancer/errinj.test.lua | 7 +++---- test/rebalancer/rebalancer.result | 5 +---- test/rebalancer/rebalancer.test.lua | 3 +-- test/rebalancer/receiving_bucket.result | 2 +- test/rebalancer/receiving_bucket.test.lua | 2 +- test/reload_evolution/storage.result | 5 +---- test/reload_evolution/storage.test.lua | 3 +-- 11 files changed, 28 insertions(+), 34 deletions(-) diff --git a/test/lua_libs/storage_template.lua b/test/lua_libs/storage_template.lua index 84e4180..21409bd 100644 --- a/test/lua_libs/storage_template.lua +++ b/test/lua_libs/storage_template.lua @@ -165,3 +165,13 @@ function wait_rebalancer_state(state, test_run) vshard.storage.rebalancer_wakeup() end end + +function wait_bucket_is_collected(id) + test_run:wait_cond(function() + if not box.space._bucket:get{id} then + return true + end + vshard.storage.recovery_wakeup() + vshard.storage.garbage_collector_wakeup() + end) +end diff --git a/test/rebalancer/bucket_ref.result b/test/rebalancer/bucket_ref.result index b66e449..b8fc7ff 100644 --- a/test/rebalancer/bucket_ref.result +++ b/test/rebalancer/bucket_ref.result @@ -243,7 +243,7 @@ vshard.storage.buckets_info(1) destination: id: 1 ... -while box.space._bucket:get{1} do vshard.storage.garbage_collector_wakeup() fiber.sleep(0.01) end +wait_bucket_is_collected(1) --- ... _ = test_run:switch('box_2_a') @@ -292,10 +292,7 @@ vshard.storage.buckets_info(1) finish_refs = true --- ... -while vshard.storage.buckets_info(1)[1].rw_lock do fiber.sleep(0.01) end ---- -... -while box.space._bucket:get{1} do fiber.sleep(0.01) end +wait_bucket_is_collected(1) --- ... _ = test_run:switch('box_1_a') diff --git a/test/rebalancer/bucket_ref.test.lua b/test/rebalancer/bucket_ref.test.lua index 49ba583..213ced3 100644 --- a/test/rebalancer/bucket_ref.test.lua +++ b/test/rebalancer/bucket_ref.test.lua @@ -73,7 +73,7 @@ vshard.storage.bucket_refro(1) finish_refs = true while f1:status() ~= 'dead' do fiber.sleep(0.01) end vshard.storage.buckets_info(1) -while box.space._bucket:get{1} do vshard.storage.garbage_collector_wakeup() fiber.sleep(0.01) end +wait_bucket_is_collected(1) _ = test_run:switch('box_2_a') vshard.storage.buckets_info(1) vshard.storage.internal.errinj.ERRINJ_LONG_RECEIVE = false @@ -89,8 +89,7 @@ while not vshard.storage.buckets_info(1)[1].rw_lock do fiber.sleep(0.01) end fiber.sleep(0.2) vshard.storage.buckets_info(1) finish_refs = true -while vshard.storage.buckets_info(1)[1].rw_lock do fiber.sleep(0.01) end -while box.space._bucket:get{1} do fiber.sleep(0.01) end +wait_bucket_is_collected(1) _ = test_run:switch('box_1_a') vshard.storage.buckets_info(1) diff --git a/test/rebalancer/errinj.result b/test/rebalancer/errinj.result index 214e7d8..e50eb72 100644 --- a/test/rebalancer/errinj.result +++ b/test/rebalancer/errinj.result @@ -237,7 +237,10 @@ _bucket:get{36} -- Buckets became 'active' on box_2_a, but still are sending on -- box_1_a. Wait until it is marked as garbage on box_1_a by the -- recovery fiber. -while _bucket:get{35} ~= nil or _bucket:get{36} ~= nil do vshard.storage.recovery_wakeup() fiber.sleep(0.001) end +wait_bucket_is_collected(35) +--- +... +wait_bucket_is_collected(36) --- ... _ = test_run:switch('box_2_a') @@ -278,7 +281,7 @@ while not _bucket:get{36} do fiber.sleep(0.0001) end _ = test_run:switch('box_1_a') --- ... -while _bucket:get{36} do vshard.storage.recovery_wakeup() vshard.storage.garbage_collector_wakeup() fiber.sleep(0.001) end +wait_bucket_is_collected(36) --- ... _bucket:get{36} @@ -295,12 +298,6 @@ box.error.injection.set('ERRINJ_WAL_DELAY', false) --- - ok ... -_ = test_run:switch('box_1_a') ---- -... -while _bucket:get{36} and _bucket:get{36}.status == vshard.consts.BUCKET.ACTIVE do fiber.sleep(0.001) end ---- -... test_run:switch('default') --- - true diff --git a/test/rebalancer/errinj.test.lua b/test/rebalancer/errinj.test.lua index 66fbe5e..2cc4a69 100644 --- a/test/rebalancer/errinj.test.lua +++ b/test/rebalancer/errinj.test.lua @@ -107,7 +107,8 @@ _bucket:get{36} -- Buckets became 'active' on box_2_a, but still are sending on -- box_1_a. Wait until it is marked as garbage on box_1_a by the -- recovery fiber. -while _bucket:get{35} ~= nil or _bucket:get{36} ~= nil do vshard.storage.recovery_wakeup() fiber.sleep(0.001) end +wait_bucket_is_collected(35) +wait_bucket_is_collected(36) _ = test_run:switch('box_2_a') _bucket:get{35} _bucket:get{36} @@ -124,13 +125,11 @@ f1 = fiber.create(function() ret1, err1 = vshard.storage.bucket_send(36, util.re _ = test_run:switch('box_2_a') while not _bucket:get{36} do fiber.sleep(0.0001) end _ = test_run:switch('box_1_a') -while _bucket:get{36} do vshard.storage.recovery_wakeup() vshard.storage.garbage_collector_wakeup() fiber.sleep(0.001) end +wait_bucket_is_collected(36) _bucket:get{36} _ = test_run:switch('box_2_a') _bucket:get{36} box.error.injection.set('ERRINJ_WAL_DELAY', false) -_ = test_run:switch('box_1_a') -while _bucket:get{36} and _bucket:get{36}.status == vshard.consts.BUCKET.ACTIVE do fiber.sleep(0.001) end test_run:switch('default') test_run:drop_cluster(REPLICASET_2) diff --git a/test/rebalancer/rebalancer.result b/test/rebalancer/rebalancer.result index 3607e93..098b845 100644 --- a/test/rebalancer/rebalancer.result +++ b/test/rebalancer/rebalancer.result @@ -334,10 +334,7 @@ vshard.storage.rebalancer_wakeup() -- Now rebalancer makes a bucket SENT. After it the garbage -- collector cleans it and deletes after a timeout. -- -while _bucket:get{91}.status ~= vshard.consts.BUCKET.SENT do fiber.sleep(0.01) end ---- -... -while _bucket:get{91} ~= nil do fiber.sleep(0.1) end +wait_bucket_is_collected(91) --- ... wait_rebalancer_state("The cluster is balanced ok", test_run) diff --git a/test/rebalancer/rebalancer.test.lua b/test/rebalancer/rebalancer.test.lua index 63e690f..308e66d 100644 --- a/test/rebalancer/rebalancer.test.lua +++ b/test/rebalancer/rebalancer.test.lua @@ -162,8 +162,7 @@ vshard.storage.rebalancer_wakeup() -- Now rebalancer makes a bucket SENT. After it the garbage -- collector cleans it and deletes after a timeout. -- -while _bucket:get{91}.status ~= vshard.consts.BUCKET.SENT do fiber.sleep(0.01) end -while _bucket:get{91} ~= nil do fiber.sleep(0.1) end +wait_bucket_is_collected(91) wait_rebalancer_state("The cluster is balanced ok", test_run) _bucket.index.status:count({vshard.consts.BUCKET.ACTIVE}) _bucket.index.status:min({vshard.consts.BUCKET.ACTIVE}) diff --git a/test/rebalancer/receiving_bucket.result b/test/rebalancer/receiving_bucket.result index db6a67f..7d3612b 100644 --- a/test/rebalancer/receiving_bucket.result +++ b/test/rebalancer/receiving_bucket.result @@ -374,7 +374,7 @@ vshard.storage.buckets_info(1) destination: id: 1 ... -while box.space._bucket:get{1} do vshard.storage.garbage_collector_wakeup() fiber.sleep(0.01) end +wait_bucket_is_collected(1) --- ... vshard.storage.buckets_info(1) diff --git a/test/rebalancer/receiving_bucket.test.lua b/test/rebalancer/receiving_bucket.test.lua index 1819cbb..24534b3 100644 --- a/test/rebalancer/receiving_bucket.test.lua +++ b/test/rebalancer/receiving_bucket.test.lua @@ -137,7 +137,7 @@ box.space.test3:select{100} _ = test_run:switch('box_2_a') vshard.storage.bucket_send(1, util.replicasets[1], {timeout = 0.3}) vshard.storage.buckets_info(1) -while box.space._bucket:get{1} do vshard.storage.garbage_collector_wakeup() fiber.sleep(0.01) end +wait_bucket_is_collected(1) vshard.storage.buckets_info(1) _ = test_run:switch('box_1_a') box.space._bucket:get{1} diff --git a/test/reload_evolution/storage.result b/test/reload_evolution/storage.result index 4652c4f..753687f 100644 --- a/test/reload_evolution/storage.result +++ b/test/reload_evolution/storage.result @@ -129,10 +129,7 @@ vshard.storage.bucket_send(bucket_id_to_move, util.replicasets[1]) --- - true ... -vshard.storage.garbage_collector_wakeup() ---- -... -while box.space._bucket:get({bucket_id_to_move}) do fiber.sleep(0.01) end +wait_bucket_is_collected(bucket_id_to_move) --- ... test_run:switch('storage_1_a') diff --git a/test/reload_evolution/storage.test.lua b/test/reload_evolution/storage.test.lua index 06f7117..639553e 100644 --- a/test/reload_evolution/storage.test.lua +++ b/test/reload_evolution/storage.test.lua @@ -51,8 +51,7 @@ vshard.storage.bucket_force_create(2000) vshard.storage.buckets_info()[2000] vshard.storage.call(bucket_id_to_move, 'read', 'do_select', {42}) vshard.storage.bucket_send(bucket_id_to_move, util.replicasets[1]) -vshard.storage.garbage_collector_wakeup() -while box.space._bucket:get({bucket_id_to_move}) do fiber.sleep(0.01) end +wait_bucket_is_collected(bucket_id_to_move) test_run:switch('storage_1_a') while box.space._bucket:get{bucket_id_to_move}.status ~= vshard.consts.BUCKET.ACTIVE do vshard.storage.recovery_wakeup() fiber.sleep(0.01) end vshard.storage.bucket_send(bucket_id_to_move, util.replicasets[2]) -- 2.24.3 (Apple Git-128)