box: do not rotate WAL when replica subscribes
Because this is pointless and confusing. This "feature" was silently introduced by commit f2bccc18 ("Use WAL vclock instead of TX vclock in most places"). Let's revert this change. This will allow us to clearly separate WAL checkpointing from WAL flushing, which will in turn facilitate implementation of the checkpoint-on-WAL-threshold feature. There are two problems here, however. First, not rotating the log breaks expectations of replication/gc test: an xlog file doesn't get deleted in time as a consequence. This happens, because we don't delete xlogs relayed to a replica after join stage is complete - we only do it during subscribe stage - and if we don't rotate WAL on subscribe the garbage collector won't be invoked. This is actually a bug - we should advance the WAL consumer associated with a replica once join stage is complete. This patch fixes it, but it unveils another problem - this time in the WAL garbage collection procedure. Turns out, when passed a vclock, the WAL garbage collection procedure removes all WAL files that were created before the vclock. Apparently, this isn't quite correct - if a consumer is in the middle of a WAL file, we must not delete the WAL file, but we do. This works as long as consumers never track vlcocks inside WAL files - currently they are advanced only when a WAL file is closed and naturally they are advanced to the beginning of the next WAL file. However, if we want to advance the consumer associated with a replica when join stage ends (this is what the previous paragraph is about), it might occur that we will advance it to the middle of a WAL file. If that happens the WAL garbage collector might remove a file which is actually in use by a replica. Fix this as well.
Showing
- src/box/box.cc 10 additions, 9 deletionssrc/box/box.cc
- src/box/wal.c 20 additions, 1 deletionsrc/box/wal.c
- src/box/wal.h 3 additions, 1 deletionsrc/box/wal.h
- test/replication/gc.result 1 addition, 7 deletionstest/replication/gc.result
- test/replication/gc.test.lua 1 addition, 5 deletionstest/replication/gc.test.lua
- test/replication/gc_no_space.result 2 additions, 2 deletionstest/replication/gc_no_space.result
- test/replication/gc_no_space.test.lua 2 additions, 2 deletionstest/replication/gc_no_space.test.lua
- test/replication/show_error_on_disconnect.result 7 additions, 5 deletionstest/replication/show_error_on_disconnect.result
- test/replication/show_error_on_disconnect.test.lua 8 additions, 2 deletionstest/replication/show_error_on_disconnect.test.lua
Loading
Please register or sign in to comment