Skip to content

Commit 8872cd9

Browse files
committed
test: stabilize <...>_sort_data_test::test_gc
This commit adds waiting for checkpoint GC results after `box.snapshot()` in the `test_gc` test case in `box-luatest/gh_10847_memtx_sort_data_test`. The checkpoint GC is asynchronous. I see less frequent `test_box_backup` failures of the same kind. I'll let the test author to work on it: there are more checks there and I don't want to break anything. Statistics over three weeks of our CI logs (from 2026-09-08 to 2026-09-29, includes re-runs made by test-run itself): | test case | arm64 | x86_64 | overall | | --------------- | ----- | ------ | ------- | | test_gc | 74 | 103 | 177 | | test_box_backup | 8 | 18 | 26 | My recipe to reproduce the instability locally: ```sh $ ./test/test-run.py $(yes box-luatest/gh_10847_memtx_sort_data_test.lua | head -n 32) ``` NO_DOC=test adjustment NO_CHANGELOG=same
1 parent 8655911 commit 8872cd9

1 file changed

Lines changed: 28 additions & 16 deletions

File tree

‎test/box-luatest/gh_10847_memtx_sort_data_test.lua‎

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -586,31 +586,43 @@ g_generic.test_gc = function(cg)
586586

587587
cg.server:exec(function()
588588
local fio = require('fio')
589-
local glob_snap = fio.pathjoin(box.cfg.memtx_dir, '*.snap')
590-
local glob_sortdata = fio.pathjoin(box.cfg.memtx_dir, '*.sortdata')
591589

592-
local prev_snapshots = nil
593-
local function check()
594-
local snapshots = fio.glob(glob_snap)
595-
local sort_data_files = fio.glob(glob_sortdata)
590+
local function snapshot_count()
591+
local glob_snap = fio.pathjoin(box.cfg.memtx_dir, '*.snap')
592+
return #fio.glob(glob_snap)
593+
end
596594

597-
t.assert_equals(#sort_data_files, #snapshots)
598-
if #snapshots < box.cfg.checkpoint_count then
599-
if prev_snapshots ~= nil then
600-
t.assert_equals(#snapshots, #prev_snapshots + 1)
601-
end
602-
else
603-
t.assert_equals(#snapshots, box.cfg.checkpoint_count)
604-
end
605-
prev_snapshots = snapshots
595+
local function sortdata_count()
596+
local glob_sortdata = fio.pathjoin(box.cfg.memtx_dir, '*.sortdata')
597+
return #fio.glob(glob_sortdata)
598+
end
599+
600+
local function check(prev_snap_count)
601+
local snap_count = snapshot_count()
602+
local sortdata_count = sortdata_count()
603+
604+
-- *.sortdata count is the same as *.snap.
605+
t.assert_equals(sortdata_count, snap_count)
606+
607+
-- *.snap count is one more than on previous check, but not above
608+
-- configured checkpoint count.
609+
local limit = box.cfg.checkpoint_count
610+
local expected_snap_count = math.min(prev_snap_count + 1, limit)
611+
t.assert_equals(snap_count, expected_snap_count)
612+
613+
return snap_count
606614
end
607615

608616
-- Create checkpoints and verify the .sortdata file count is valid.
617+
local snap_count = snapshot_count()
609618
assert(box.cfg.checkpoint_count == 2) -- The expected default value.
610619
for i = 1, box.cfg.checkpoint_count * 2 do -- luacheck: no unused
611620
box.space._space:alter({}) -- No-op to update the VClock.
612621
box.snapshot()
613-
check()
622+
623+
-- Checkpoint GC is asynchronous, so we have to check with
624+
-- retries.
625+
snap_count = t.helpers.retrying({timeout = 20}, check, snap_count)
614626
end
615627
end)
616628
end

0 commit comments

Comments
 (0)