vinyl: fix index name in duplicate key error message
The code setting ER_TUPLE_FOUND uses index_name_by_id() to find the index name, but it passes an index in the dense index map to it while the function expects an index in the sparse index map. Apparently, this doesn't work as expected after an index is removed from the middle of the index map. This bug was introduced by commit fc3834c0 ("vinyl: check key uniqueness before modifying tx write set"). Instead of just fixing the index passed to index_name_by_id(), we do a bit of refactoring. We stop passing index_name and space_name to vy_check_is_unique_*() functions and instead get them right before raising ER_TUPLE_FOUND. Note, to get the space name, we need to call space_by_id() but it should be fine because (a) the space is very likely to be cached as the last accessed one and (b) this is an error path so it isn't performance critical. We also drop index_name_by_id() and extract the index name from the LSM tree object. Closes #5975 NO_DOC=bug fix (cherry picked from commit 2cfba5eb)
Showing
- changelogs/unreleased/gh-5975-vy-duplicate-key-error-fix.md 3 additions, 0 deletionschangelogs/unreleased/gh-5975-vy-duplicate-key-error-fix.md
- src/box/space.c 0 additions, 9 deletionssrc/box/space.c
- src/box/space.h 0 additions, 12 deletionssrc/box/space.h
- src/box/vinyl.c 16 additions, 39 deletionssrc/box/vinyl.c
- test/engine-luatest/gh_5975_duplicate_key_error_test.lua 60 additions, 0 deletionstest/engine-luatest/gh_5975_duplicate_key_error_test.lua
Loading
Please register or sign in to comment