vinyl: fix race between compaction and gc of dropped LSM
An LSM tree (space index, that is) can be dropped while compaction is in progress for it. In this case compaction will still commit the new run to vylog upon completion. This usually works fine, but not if gc has already purged all the information about the dropped LSM tree from vylog by that time, in which case an attempt to commit the new run will result in permanently broken vylog (because compaction will write vylog records for a non-existing object): ER_INVALID_VYLOG_FILE: Invalid VYLOG file: Slice 13 deleted but not registered To prevent this from happening, let's make compaction silently drop the new run without committing it to vylog if the LSM tree has been dropped. This should work just fine - since the LSM tee isn't used anymore we don't need to have it compacted, neither do we need to delete the run, since gc will eventually clean up all artefacts left from the dropped LSM tree. One thing to be noted is that we also must exclude dropped LSM trees from further compaction - if we don't do that, we might end up picking the dropped LSM tree for compaction over and over again (because it isn't actually compacted). This patch also drops the gh-5141-invalid-vylog-file test, because the latter just ensured that the issue fixed by this patch is there. Closes #5436
Showing
- src/box/vy_lsm.c 9 additions, 0 deletionssrc/box/vy_lsm.c
- src/box/vy_scheduler.c 12 additions, 1 deletionsrc/box/vy_scheduler.c
- test/vinyl/gh-5141-invalid-vylog-file.result 0 additions, 140 deletionstest/vinyl/gh-5141-invalid-vylog-file.result
- test/vinyl/gh-5141-invalid-vylog-file.skipcond 0 additions, 6 deletionstest/vinyl/gh-5141-invalid-vylog-file.skipcond
- test/vinyl/gh-5141-invalid-vylog-file.test.lua 0 additions, 72 deletionstest/vinyl/gh-5141-invalid-vylog-file.test.lua
- test/vinyl/gh-5436-vylog-gc-during-compaction.result 84 additions, 0 deletionstest/vinyl/gh-5436-vylog-gc-during-compaction.result
- test/vinyl/gh-5436-vylog-gc-during-compaction.test.lua 35 additions, 0 deletionstest/vinyl/gh-5436-vylog-gc-during-compaction.test.lua
- test/vinyl/suite.ini 1 addition, 1 deletiontest/vinyl/suite.ini
Loading