Skip to content

Deleted tuple isn't purged from secondary index of vinyl space #10820

@locker

Description

@locker

Bug description

Under certain conditions, a deleted tuple isn't purged from a secondary index of a vinyl space.

Tarantool 3.3.0-entrypoint-199-g5325abd3441e
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'}

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

s:replace{1, 2}

box.begin()
s:replace{1, 1}
s:replace{1, 1}
box.commit()

box.snapshot()

print(string.format('primary: count = %d, len = %d',
                    s.index.primary:count(), s.index.primary:len()))
print(string.format('secondary: count = %d, len = %d',
                    s.index.secondary:count(), s.index.secondary:len()))
os.exit(0)

Actual behavior

Output:

primary: count = 1, len = 1
secondary: count = 1, len = 2

Note that discrepancy between len and count for the secondary index. They should be the same because the index is compacted.

$ $ tt cat 512/1/00000000000000000004.run
   • Running cat with files: [512/1/00000000000000000004.run]

• Result of cat: the file "512/1/00000000000000000004.run" is processed below •
---
HEADER:
  lsn: 6
  type: REPLACE
BODY:
  tuple: [1, 1]
---
HEADER:
  lsn: 4
  type: INSERT
BODY:
  tuple: [2, 1]
---
HEADER:
  type: ROWINDEX
BODY:
  data: !!binary AAAAAAAAAAo=
...

Tuple {1, 2} wasn't purged from the secondary index run file although it was deleted from the primary index.

Expected behavior

count and len should be the same.

Notes

  • The issue doesn't seem to be critical because it doesn't result in invalid select results. The only side-effect is piling up garbage in secondary indexes.

  • The issue results in vinyl-luatest/select_consistency_test.lua failures. To increase the probability of a failure, apply the patch below to the test.

    test patch
    diff --git a/test/vinyl-luatest/select_consistency_test.lua b/test/vinyl-luatest/select_consistency_test.lua
    index 22feac904a6f..f5ae01aad852 100644
    --- a/test/vinyl-luatest/select_consistency_test.lua
    +++ b/test/vinyl-luatest/select_consistency_test.lua
    @@ -73,11 +73,11 @@ g.test_select_consistency = function(cg)
                 local WRITE_FIBERS = 20
                 local READ_FIBERS = 5
                 local MAX_TX_STMTS = 10
    -            local MAX_KEY = 100 * 1000
    +            local MAX_KEY = 1000
                 local MAX_VAL = 1000
                 local MAX_MULTIKEY_COUNT = 10
                 local PADDING_SIZE = 100
    -            local DUMP_COUNT = 5
    +            local DUMP_COUNT = 1
     
                 local s = box.space.test
     
    test failure report
    Tarantool version is 3.3.0-entrypoint-199-g5325abd3441e
    Started on Fri Nov 15 16:36:58 2024
        vinyl.select_consistency.defer_deletes:false.test_select_consistency ... (2.929s) fail
    ...tarantool/test/vinyl-luatest/select_consistency_test.lua:241: expected: 658, actual: 666
        vinyl.select_consistency.defer_deletes:true.test_select_consistency ... (2.917s) fail
    ...tarantool/test/vinyl-luatest/select_consistency_test.lua:241: expected: 671, actual: 672
    =========================================================
    
    Failed tests:
    -------------
    
    1) vinyl.select_consistency.defer_deletes:false.test_select_consistency
    ...tarantool/test/vinyl-luatest/select_consistency_test.lua:241: expected: 658, actual: 666
    stack traceback:
            ...tarantool/test/vinyl-luatest/select_consistency_test.lua:241: in function <...tarantool/test/vinyl-luatest/select_consistency_test.lua:217>
            ...tarantool/test/vinyl-luatest/select_consistency_test.lua:217: in function 'vinyl.select_consistency.defer_deletes:false.test_select_consistency'
    artifacts:
            master -> /tmp/t/artifacts/master-DlSbSoaS-fdB
    2) vinyl.select_consistency.defer_deletes:true.test_select_consistency
    ...tarantool/test/vinyl-luatest/select_consistency_test.lua:241: expected: 671, actual: 672
    stack traceback:
            ...tarantool/test/vinyl-luatest/select_consistency_test.lua:241: in function <...tarantool/test/vinyl-luatest/select_consistency_test.lua:217>
            ...tarantool/test/vinyl-luatest/select_consistency_test.lua:217: in function 'vinyl.select_consistency.defer_deletes:true.test_select_consistency'
    artifacts:
            master -> /tmp/t/artifacts/master-jg7jA8UlxS33
    Ran 2 tests in 6.762 seconds, 0 succeeded, 2 failed
    
    =========================================================
    Failed tests:
    
    vinyl.select_consistency.defer_deletes:false.test_select_consistency
    vinyl.select_consistency.defer_deletes:true.test_select_consistency
    

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 workingvinyl

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions