Skip to content

Vinyl crashes trying to update duplicate multikey index field with deferred deletes #10869

@locker

Description

@locker

Bug description

The following assertion is triggered while executing a transaction that updates a multikey index field with duplicates from its own write set on a space with enabled defer_deletes option:

tarantool: ./src/box/tuple_compare.cc:750: int tuple_compare_slowpath(tuple*, hint_t, tuple*, hint_t, key_def*) [with bool is_nullable = false; bool has_optional_parts = false; bool has_json_paths = true; bool is_multikey = true; bool has_desc_parts = false; hint_t = long unsigned int]: Assertion `has_optional_parts || (field_a != NULL && field_b != NULL)' failed.
Aborted (core dumped)

Stack trace:

#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x00007778ae24526e in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00007778ae2288ff in __GI_abort () at ./stdlib/abort.c:79
#5  0x00007778ae22881b in __assert_fail_base (fmt=0x7778ae3d01e8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
    assertion=assertion@entry=0x5d0e7c018720 "has_optional_parts || (field_a != NULL && field_b != NULL)", file=file@entry=0x5d0e7c017761 "./src/box/tuple_compare.cc",
    line=line@entry=750,
    function=function@entry=0x5d0e7c01c558 "int tuple_compare_slowpath(tuple*, hint_t, tuple*, hint_t, key_def*) [with bool is_nullable = false; bool has_optional_parts = false; bool has_json_paths = true; bool is_multikey = true; bool has_desc"...) at ./assert/assert.c:94
#6  0x00007778ae23b507 in __assert_fail (assertion=0x5d0e7c018720 "has_optional_parts || (field_a != NULL && field_b != NULL)",
    file=0x5d0e7c017761 "./src/box/tuple_compare.cc", line=750,
    function=0x5d0e7c01c558 "int tuple_compare_slowpath(tuple*, hint_t, tuple*, hint_t, key_def*) [with bool is_nullable = false; bool has_optional_parts = false; bool has_json_paths = true; bool is_multikey = true; bool has_desc"...) at ./assert/assert.c:103
#7  0x00005d0e7bc66116 in tuple_compare_slowpath<false, false, true, true, false> (tuple_a=0x777893000030, tuple_a_hint=0, tuple_b=0x777893018098, tuple_b_hint=1,
    key_def=0x5d0e7dc7a7f0) at /home/vlad/src/tarantool/tarantool/src/box/tuple_compare.cc:750
#8  0x00005d0e7b711708 in tuple_compare (tuple_a=0x777893000030, tuple_a_hint=0, tuple_b=0x777893018098, tuple_b_hint=1, key_def=0x5d0e7dc7a7f0)
    at /home/vlad/src/tarantool/tarantool/src/box/key_def.h:1086
#9  0x00005d0e7b711eb8 in vy_stmt_compare (a=0x777893000030, a_hint=0, b=0x777893018098, b_hint=1, key_def=0x5d0e7dc7a7f0)
    at /home/vlad/src/tarantool/tarantool/src/box/vy_stmt.h:435
#10 0x00005d0e7b7120c7 in vy_entry_compare (a=..., b=..., key_def=0x5d0e7dc7a7f0) at /home/vlad/src/tarantool/tarantool/src/box/vy_stmt.h:783
#11 0x00005d0e7b712161 in vy_mem_tree_cmp (a=..., b=..., cmp_def=0x5d0e7dc7a7f0) at /home/vlad/src/tarantool/tarantool/src/box/vy_mem.h:93
#12 0x00005d0e7b712847 in bps_tree_vy_mem_tree_find_ins_point_elem (tree=0x5d0e7dc78ca8, arr=0x777893014070, size=2, elem=..., exact=0x7778ab58039a)
    at /home/vlad/src/tarantool/tarantool/src/lib/salad/bps_tree.h:2093
#13 0x00005d0e7b71ae30 in bps_tree_vy_mem_tree_collect_path (touch_leaf=true, exact=0x7778ab58039a, leaf_path_elem=0x7778ab580460, path=0x7778ab580490, new_elem=...,
    tree=0x5d0e7dc78ca8) at /home/vlad/src/tarantool/tarantool/src/lib/salad/bps_tree.h:3350
#14 bps_tree_vy_mem_tree_insert (offset=0x0, inserted_iterator=0x0, successor=0x0, replaced=0x7778ab5807e0, new_elem=..., t=0x5d0e7dc78ca8)
    at /home/vlad/src/tarantool/tarantool/src/lib/salad/bps_tree.h:5835
#15 vy_mem_tree_insert (t=0x5d0e7dc78ca8, new_elem=..., replaced=0x7778ab5807e0, successor=0x0) at /home/vlad/src/tarantool/tarantool/src/lib/salad/bps_tree.h:5880
#16 0x00005d0e7b71ca33 in vy_mem_insert (mem=0x5d0e7dc78c90, entry=..., count=0x5d0e7dc74538) at /home/vlad/src/tarantool/tarantool/src/box/vy_mem.c:242
#17 0x00005d0e7b733b37 in vy_lsm_set (lsm=0x5d0e7dc74410, mem=0x5d0e7dc78c90, entry=..., region_stmt=0x7778ab580928)
    at /home/vlad/src/tarantool/tarantool/src/box/vy_lsm.c:934
#18 0x00005d0e7b73f31a in vy_tx_write (lsm=0x5d0e7dc74410, mem=0x5d0e7dc78c90, entry=..., region_stmt=0x7778ab580928)
    at /home/vlad/src/tarantool/tarantool/src/box/vy_tx.c:551
#19 0x00005d0e7b73fdca in vy_tx_prepare (tx=0x7778ab86c070) at /home/vlad/src/tarantool/tarantool/src/box/vy_tx.c:810
#20 0x00005d0e7b705e9d in vinyl_engine_prepare (engine=0x5d0e7dc424b0, txn=0x7778ab825038) at /home/vlad/src/tarantool/tarantool/src/box/vinyl.c:2464
#21 0x00005d0e7b7b36e4 in engine_prepare (engine=0x5d0e7dc424b0, txn=0x7778ab825038) at /home/vlad/src/tarantool/tarantool/src/box/engine.h:414
#22 0x00005d0e7b7b8a7d in txn_prepare (txn=0x7778ab825038) at /home/vlad/src/tarantool/tarantool/src/box/txn.c:1098
#23 0x00005d0e7b7b8f5d in txn_commit_impl (txn=0x7778ab825038, wait_mode=TXN_COMMIT_WAIT_MODE_COMPLETE) at /home/vlad/src/tarantool/tarantool/src/box/txn.c:1182
#24 0x00005d0e7b7b9c75 in box_txn_commit_ex (wait_mode=TXN_COMMIT_WAIT_MODE_COMPLETE) at /home/vlad/src/tarantool/tarantool/src/box/txn.c:1392
#25 0x00005d0e7b8d3bca in lbox_commit (L=0x40d84378) at /home/vlad/src/tarantool/tarantool/src/box/lua/init.c:538
#26 0x00005d0e7b9c7867 in lj_BC_FUNCC () at buildvm_x86.dasc:811
#27 0x00005d0e7b9d53ab in lua_pcall (L=0x40d84378, nargs=0, nresults=0, errfunc=0) at /home/vlad/src/tarantool/tarantool/third_party/luajit/src/lj_api.c:1173
#28 0x00005d0e7b932c73 in luaT_call (L=0x40d84378, nargs=0, nreturns=0) at /home/vlad/src/tarantool/tarantool/src/lua/utils.c:708
#29 0x00005d0e7b924039 in lua_main (L=0x40d84378, is_debugging=false, argc=1, argv=0x5d0e7dbf1e98) at /home/vlad/src/tarantool/tarantool/src/lua/init.c:926
#30 0x00005d0e7b924c53 in run_script_f (ap=0x7778ab810a30) at /home/vlad/src/tarantool/tarantool/src/lua/init.c:1139
#31 0x00005d0e7b67a183 in fiber_cxx_invoke(fiber_func, typedef __va_list_tag __va_list_tag *) (f=0x5d0e7b924052 <run_script_f>, ap=0x7778ab810a30)
    at /home/vlad/src/tarantool/tarantool/src/lib/core/fiber.h:1324
#32 0x00005d0e7b9644c7 in fiber_loop (data=0x0) at /home/vlad/src/tarantool/tarantool/src/lib/core/fiber.c:1167
#33 0x00005d0e7bd9536b in coro_init () at /home/vlad/src/tarantool/tarantool/third_party/coro/coro.c:108

Tarantool version:

Tarantool 3.3.0-entrypoint-269-g6a214e42e707
Target: Linux-x86_64-Debug
Build options: cmake . -DCMAKE_INSTALL_PREFIX=/home/vlad/src/tarantool/tarantool/build/debug/install -DENABLE_BACKTRACE=TRUE
Compiler: GNU-13.2.0
C_FLAGS: -fexceptions -funwind-tables -fasynchronous-unwind-tables -fno-common -msse2 -Wformat -Wformat-security -Werror=format-security -fstack-protector-strong -fPIC -fmacro-prefix-map=/home/vlad/src/tarantool/tarantool=. -std=c11 -Wall -Wextra -Wno-gnu-alignof-expression -fno-gnu89-inline -Wno-cast-function-type -Werror -g -ggdb -O0
CXX_FLAGS: -fexceptions -funwind-tables -fasynchronous-unwind-tables -fno-common -msse2 -Wformat -Wformat-security -Werror=format-security -fstack-protector-strong -fPIC -fmacro-prefix-map=/home/vlad/src/tarantool/tarantool=. -std=c++11 -Wall -Wextra -Wno-invalid-offsetof -Wno-gnu-alignof-expression -Wno-cast-function-type -Werror -g -ggdb -O0

Steps to reproduce

Run the following script:

os.execute('rm -rf [0-9]*')

box.cfg{
    log_level = 'warn',
    vinyl_defer_deletes = true,
}

local s = box.schema.space.create('test', {engine = 'vinyl'})
s:create_index('primary')
s:create_index('secondary', {
    unique = false,
    parts = {{'[2][*]', 'unsigned'}},
})

s:insert({1, {10}})

box.begin()
s:replace({1, {1, 1}})
s:update({1}, {{'=', 2, {2, 3, 4}}})
box.commit()

os.exit(0)

Actual behavior

Assertion failure.

Expected behavior

The script exits without errors.

Notes

The crash happens only if the defer_deletes space option is enabled. By default it is disabled.

Related issue: #10870

Metadata

Metadata

Assignees

Labels

2.11Target is 2.11 and all newer release/master branches3.2Target is 3.2 and all newer release/master branchesbugSomething isn't workingcrashvinyl

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions