vinyl: fix crash in index drop if there is DML request reading from it
A DML request (insert, replace, update) can yield while reading from the disk in order to check unique constraints. In the meantime the index can be dropped. The DML request can't crash in this case thanks to commit d3e12369 ("vinyl: abort affected transactions when space is removed from cache"), but the DDL operation can because: - It unreferences the index in `alter_space_commit`, which may result in dropping the LSM tree with `vy_lsm_delete`. - `vy_lsm_delete` may yield in `vy_range_tree_free_cb` while waiting for disk readers to complete. - Yielding in commit triggers isn't allowed (crashes). We already fixed a similar issue when `index.get` crashed if raced with index drop, see commit 75f03a50 ("vinyl: fix crash if space is dropped while space.get is reading from it"). Let's fix this issue in the same way - by taking a reference to the LSM tree while checking unique constraints. To do that it's enough to move `vy_lsm_ref` from `vinyl_index_get` to `vy_get`. Also, let's replace `vy_slice_wait_pinned` with an assertion checking that the slice pin count is 0 in `vy_range_tree_free_cb` because `vy_lsm_delete` must not yield. Closes #10094 NO_DOC=bug fix (cherry picked from commit bde28f0f)
Showing
- changelogs/unreleased/gh-10094-vy-index-drop-crash-fix.md 4 additions, 0 deletionschangelogs/unreleased/gh-10094-vy-index-drop-crash-fix.md
- src/box/vinyl.c 13 additions, 10 deletionssrc/box/vinyl.c
- src/box/vy_lsm.c 1 addition, 1 deletionsrc/box/vy_lsm.c
- test/vinyl-luatest/gh_10094_index_drop_test.lua 44 additions, 0 deletionstest/vinyl-luatest/gh_10094_index_drop_test.lua
Loading
Please register or sign in to comment