vinyl: fix bug when tuple not committed to unique nullable index
A unique nullable key definition extended with primary key parts (cmp_def) assumes that two tuples are equal *without* comparing primary key fields if all secondary key fields are equal and not nulls, see tuple_compare_slowpath(). This is a hack required to ignore the uniqueness constraint for nulls in memtx. The memtx engine can't use the secondary key definition as is (key_def) for comparing tuples in the index tree, as it does for a non-nullable unique index, because this wouldn't allow insertion of any duplicates, including nulls. It couldn't use cmp_def without this hack, either, because then conflicting tuples with the same secondary key fields would always compare as not equal due to different primary key parts. For Vinyl, this hack isn't required because it explicitly skips the uniqueness check if any of the indexed fields are nulls, see vy_check_is_unique_secondary(). Furthermore, this hack is harmful because Vinyl relies on the fact that two tuples compare as equal by cmp_def if and only if *all* key fields (both secondary and primary) are equal. For example, this is used in the transaction manager, which overwrites statements equal by cmp_def, see vy_tx_set_entry(). Let's disable this hack by resetting unique_part_count in cmp_def. Closes #9769 NO_DOC=bug fix (cherry picked from commit 2e689063)
Showing
- changelogs/unreleased/gh-9769-vy-unique-nullable-index-fix.md 4 additions, 0 deletions...gelogs/unreleased/gh-9769-vy-unique-nullable-index-fix.md
- src/box/vy_lsm.c 25 additions, 0 deletionssrc/box/vy_lsm.c
- test/engine-luatest/gh_9769_tuple_lost_in_unique_nullable_index_test.lua 45 additions, 0 deletions...test/gh_9769_tuple_lost_in_unique_nullable_index_test.lua
Loading
Please register or sign in to comment