gc: run garbage collection in background
Currently, garbage collection is executed synchronously by functions that may trigger it, such as gc_consumer_advance or gc_add_checkpoint. As a result, one has to be very cautious when using those functions as they may yield at their will. For example, we can't shoot off stale consumers right in tx_prio handler - we have to use rather clumsy WAL watcher interface instead. Besides, in future, when the garbage collector state is persisted, we will need to call those functions from on_commit trigger callback, where yielding is not normally allowed. Actually, there's no reason to remove old files synchronously - we could as well do it in the background. So this patch introduces a background garbage collection fiber that executes gc_run when woken up. Now all functions that might trigger garbage collection wake up this fiber instead of executing gc_run directly.
Showing
- src/box/box.cc 12 additions, 0 deletionssrc/box/box.cc
- src/box/gc.c 63 additions, 16 deletionssrc/box/gc.c
- src/box/gc.h 29 additions, 6 deletionssrc/box/gc.h
- test/replication/gc.result 4 additions, 0 deletionstest/replication/gc.result
- test/replication/gc.test.lua 1 addition, 0 deletionstest/replication/gc.test.lua
Please register or sign in to comment