Skip to content
Snippets Groups Projects
Commit cd9fd77e authored by Vladimir Davydov's avatar Vladimir Davydov Committed by Vladimir Davydov
Browse files

test: fix flaky vinyl/gc test

The commit fixes the following test failure:

```
[013] vinyl/gc.test.lua                                               [ fail ]
[013]
[013] Test failed! Result content mismatch:
[013] --- vinyl/gc.result	Fri Dec 24 12:27:33 2021
[013] +++ /build/usr/src/debug/tarantool-2.10.0~beta2.18.dev/test/var/rejects/vinyl/gc.reject	Thu Dec 30 10:29:29 2021
[013] @@ -102,7 +102,7 @@
[013]  ...
[013]  check_files_number(2)
[013]  ---
[013] -- true
[013] +- null
[013]  ...
[013]  -- All records should have been purged from the log by now
[013]  -- so we should only keep the previous log file.
```

The reason of the failure is that vylog files are deleted asynchronously
(`box.snapshot()` doesn't wait for `unlink` to complete) since commit
8e429f4b ("wal: remove old xlog files
asynchronously"). So to fix the test, we just need to make the test wait
for garbage collection to complete.

Follow-up #5383
parent 68c29688
No related branches found
No related tags found
No related merge requests found
......@@ -42,9 +42,11 @@ function ls_vylog() return fio.glob(fio.pathjoin(box.cfg.vinyl_dir, '*.vylog'))
function gc() temp:auto_increment{} box.snapshot() end
---
...
function check_files_number(fnum) return (#files == fnum or \
(require('log').error(files) or \
require('log').error(box.info.gc()))) end
function wait_gc(ls_files, expected_count) \
return test_run:wait_cond(function() \
return #ls_files() == expected_count \
end) \
end
---
...
-- Check that run files are deleted by gc.
......@@ -60,18 +62,12 @@ while s.index.pk:stat().run_count > 1 do fiber.sleep(0.01) end -- wait for compa
gc()
---
...
files = ls_data()
---
...
check_files_number(2)
assert(wait_gc(ls_data, 2))
---
- true
...
-- Check that gc keeps the current and previous log files.
files = ls_vylog()
---
...
check_files_number(2)
assert(wait_gc(ls_vylog, 2))
---
- true
...
......@@ -82,10 +78,7 @@ s:drop()
gc()
---
...
files = ls_data()
---
...
check_files_number(0)
assert(wait_gc(ls_data, 0))
---
- true
...
......@@ -97,10 +90,7 @@ check_files_number(0)
gc()
---
...
files = ls_vylog()
---
...
check_files_number(2)
assert(wait_gc(ls_vylog, 2))
---
- true
...
......@@ -109,10 +99,7 @@ check_files_number(2)
gc()
---
...
files = ls_vylog()
---
...
check_files_number(1)
assert(wait_gc(ls_vylog, 1))
---
- true
...
......@@ -120,10 +107,7 @@ check_files_number(1)
gc()
---
...
files = ls_vylog()
---
...
check_files_number(0)
assert(wait_gc(ls_vylog, 0))
---
- true
...
......
......@@ -20,27 +20,26 @@ path = fio.pathjoin(box.cfg.vinyl_dir, tostring(s.id), tostring(s.index.pk.id))
function ls_data() return fio.glob(fio.pathjoin(path, '*')) end
function ls_vylog() return fio.glob(fio.pathjoin(box.cfg.vinyl_dir, '*.vylog')) end
function gc() temp:auto_increment{} box.snapshot() end
function check_files_number(fnum) return (#files == fnum or \
(require('log').error(files) or \
require('log').error(box.info.gc()))) end
function wait_gc(ls_files, expected_count) \
return test_run:wait_cond(function() \
return #ls_files() == expected_count \
end) \
end
-- Check that run files are deleted by gc.
s:insert{1} box.snapshot() -- dump
s:insert{2} box.snapshot() -- dump + compaction
while s.index.pk:stat().run_count > 1 do fiber.sleep(0.01) end -- wait for compaction
gc()
files = ls_data()
check_files_number(2)
assert(wait_gc(ls_data, 2))
-- Check that gc keeps the current and previous log files.
files = ls_vylog()
check_files_number(2)
assert(wait_gc(ls_vylog, 2))
-- Check that files left from dropped indexes are deleted by gc.
s:drop()
gc()
files = ls_data()
check_files_number(0)
assert(wait_gc(ls_data, 0))
--
-- Check that vylog files are removed if vinyl is not used.
......@@ -49,19 +48,16 @@ check_files_number(0)
-- This purges records corresponding to dropped runs, but
-- dropped index records are still stored in vylog.
gc()
files = ls_vylog()
check_files_number(2)
assert(wait_gc(ls_vylog, 2))
-- All records should have been purged from the log by now
-- so we should only keep the previous log file.
gc()
files = ls_vylog()
check_files_number(1)
assert(wait_gc(ls_vylog, 1))
-- The previous log file should be removed by the next gc.
gc()
files = ls_vylog()
check_files_number(0)
assert(wait_gc(ls_vylog, 0))
temp:drop()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment