box: don't delete inprogress files during normal GC
*.inprogress files shouldn't be deleted during normal GC, because they may be in use. E.g. GC may happen to run while WAL is rotating xlog; if GC removes the transient xlog.inprogress file created by WAL (see xdir_create_xlog), WAL will fail to rename it and abort the current transaction. Initially, inprogress files were removed only after recovery. For this reason, xdir_collect_inprogress, which is used for deleting inprogress files, accesses FS directly, without COIO. This was changed by commit 5aa243de ("recovery: build secondary index in hot standby mode") which moved xdir_collect_inprogress from memtx_engine_end_recovery to memtx_engine_collect_garbage so that a hot standby instance doesn't delete inprogress files of the master instance by mistake. To fix this issue, let's move xdir_collect_inprogress back where it belongs, to engine_end_recovery, and introduce a new callback for memtx to build its secondary keys before entering the hot standby mode - engine_begin_hot_standby. Let's also remove engine_collect_garbage from gc_init, which was added there by the aforementioned commit, probably to make tests pass. The bug was reported by the vinyl/deferred_delete test (#5089). Closes #6554
Showing
- changelogs/unreleased/gh-6554-fix-gc-removing-inprogress-xlogs.md 4 additions, 0 deletions...gs/unreleased/gh-6554-fix-gc-removing-inprogress-xlogs.md
- src/box/blackhole.c 1 addition, 0 deletionssrc/box/blackhole.c
- src/box/box.cc 3 additions, 1 deletionsrc/box/box.cc
- src/box/engine.c 18 additions, 0 deletionssrc/box/engine.c
- src/box/engine.h 19 additions, 1 deletionsrc/box/engine.h
- src/box/gc.c 0 additions, 1 deletionsrc/box/gc.c
- src/box/memtx_engine.cc 23 additions, 4 deletionssrc/box/memtx_engine.cc
- src/box/service_engine.c 1 addition, 0 deletionssrc/box/service_engine.c
- src/box/sysview.c 1 addition, 0 deletionssrc/box/sysview.c
- src/box/vinyl.c 1 addition, 0 deletionssrc/box/vinyl.c
- src/box/xlog.c 2 additions, 0 deletionssrc/box/xlog.c
- src/lib/core/errinj.h 1 addition, 0 deletionssrc/lib/core/errinj.h
- test/box/errinj.result 1 addition, 0 deletionstest/box/errinj.result
- test/box/gh-6554-gc-removes-inprogress-xlogs.result 118 additions, 0 deletionstest/box/gh-6554-gc-removes-inprogress-xlogs.result
- test/box/gh-6554-gc-removes-inprogress-xlogs.test.lua 56 additions, 0 deletionstest/box/gh-6554-gc-removes-inprogress-xlogs.test.lua
- test/box/suite.ini 1 addition, 1 deletiontest/box/suite.ini
Loading
Please register or sign in to comment