vinyl: fix crash during secondary index recovery
A secondary index creation proceeds as follows: 1. Build the new index by inserting statements from the primary index, see vinyl_space_build_index(). 2. Dump the new index and wait for the dump to complete. 3. Commit the index creation record to the WAL. While the new index is being dumped at step 2, new statements may be inserted into the space. We need to insert those statements during recovery, see vy_build_recover(). We identify such statements by comparing LSN to vy_lsm::dump_lsn, see vy_build_recover_stmt(). It might occur that the newly built index is empty while the primary index memory level isn't - if all statements cancel each other. In this case, the secondary index won't be dumped during creation and its dump_lsn will be set to -1, see the vy_lsm_is_empty() check in vinyl_space_build_index(). This would break the assumption made on recovery: that all statements with LSN > vy_lsm::dump_lsn should be inserted into the secondary index. If a statement like this isn't compatible with the new index, we will get a crash trying to insert it. Let's fix this issue by skipping vy_build_recover() in case the new secondary index was never dumped. Closes #6778 NO_DOC=bug fix (cherry picked from commit dadb8d70)
Showing
- changelogs/unreleased/gh-6778-vinyl-recovery-crash.md 4 additions, 0 deletionschangelogs/unreleased/gh-6778-vinyl-recovery-crash.md
- src/box/vinyl.c 13 additions, 0 deletionssrc/box/vinyl.c
- test/vinyl-luatest/gh_6778_recovery_crash_test.lua 33 additions, 0 deletionstest/vinyl-luatest/gh_6778_recovery_crash_test.lua
Loading
Please register or sign in to comment