memtx: fix a bug with mvcc and exclude_null option
Before this patch MVCC engine expected that if index_replace sets `result` to NULL then index_replace sets `successor` to something (NULL or existing tuple, depending on index type). That looked fine because by contract `successor` is set when true insertion was happened. Unfortunately it was not considered that in case of part with `exclude_null` option in index the insertion can be silently skipped and thus `successor` can be not set. The latter access of it was actually an UB. Fix it by explicit check of tuple_key_is_excluded and work on this case correctly. Note that logically `index_replace` should return a flag whether the new tuple was filtered (excluded) by key_def. But on the other hand this flag is required only for mvcc while the function is already has lots of arguments and it's very cheap to determine this flag right from memtx_tx, so I decided to make the most simple patch. NO_DOC=bugfix (cherry picked from commit 14e21297)
Showing
- changelogs/unreleased/gh-9954-mvcc-crash-with-exclude-null.md 3 additions, 0 deletions...gelogs/unreleased/gh-9954-mvcc-crash-with-exclude-null.md
- src/box/memtx_tx.c 28 additions, 6 deletionssrc/box/memtx_tx.c
- test/box-luatest/gh_9954_mvcc_with_exclude_null_test.lua 109 additions, 0 deletionstest/box-luatest/gh_9954_mvcc_with_exclude_null_test.lua
Loading
Please register or sign in to comment