recovery: make it yield when positioning in a WAL
We had various places in box.cc and relay.cc which counted processed rows and yielded every now and then. These yields didn't cover cases, when recovery has to position inside a long WAL file: For example, when tarantool exits without leaving an empty WAL file which will be used to recover instance vclock on restart. In this case the instance freezes while processing the last available WAL in order to recover the vclock. Another issue is with replication. If a replica connects and needs data from the end of a really long WAL, recovery will read up to the needed position without yields, making relay disconnect by timeout. In order to fix the issue, make recovery decide when a yield should happen. Once recovery decides so, it calls a xstream callback, schedule_yield. Currently schedule_yield is fired once recovery processes (either skips or writes) WAL_ROWS_PER_YIELD rows. schedule_yield either yields right away, in case of relay, or saves the yield for later, in case of local recovery, because it might be in the middle of a transaction. Closes #5979
Showing
- changelogs/unreleased/gh-5979-recovery-yield.md 12 additions, 0 deletionschangelogs/unreleased/gh-5979-recovery-yield.md
- src/box/box.cc 16 additions, 16 deletionssrc/box/box.cc
- src/box/memtx_engine.c 1 addition, 0 deletionssrc/box/memtx_engine.c
- src/box/recovery.cc 14 additions, 9 deletionssrc/box/recovery.cc
- src/box/recovery.h 1 addition, 1 deletionsrc/box/recovery.h
- src/box/relay.cc 9 additions, 8 deletionssrc/box/relay.cc
- src/box/vinyl.c 1 addition, 0 deletionssrc/box/vinyl.c
- src/box/xstream.h 25 additions, 1 deletionsrc/box/xstream.h
Loading