Skip to content

mvcc: rollback may cause duplicates in secondary indexes #11660

@Astronomax

Description

@Astronomax

Bug description

Rollback may cause duplicates in secondary indexes.

Steps to reproduce

Run the following reproducer.lua script:

fiber = require('fiber')

box.cfg{memtx_use_mvcc_engine=true}

box.schema.space.create("test")
box.space.test:format{{'a', type='unsigned'}, {'b', type='unsigned'}}
box.space.test:create_index("pk", {parts={{'a'}}})
box.space.test:create_index("sk", {parts={{'b'}}, unique=true})

box.space.test:truncate()

box.space.test:insert{1, 1}
box.space.test:insert{2, 2}

-- block WAL queue
box.cfg{wal_queue_max_size=1}
box.error.injection.set('ERRINJ_WAL_DELAY', true)
box.begin()
	box.space.test:insert{10000, 10000}
box.commit({wait='none'})

f1 = fiber.create(function()
	box.space.test:replace{2, 3}
end)
f1:set_joinable(true)

f2 = fiber.create(function()
	box.begin()
		box.space.test:replace{1, 2}
		fiber.sleep(5)
	box.commit()
end)
f2:set_joinable(true)

box.error.injection.set('ERRINJ_WAL_IO', true)
box.error.injection.set('ERRINJ_WAL_DELAY', false)

local ok, err = f1:join()
print(ok, err)

box.error.injection.set('ERRINJ_WAL_IO', false)

ok, err = f2:join()
print(ok, err)

print(require('yaml').encode(box.space.test:select{}))

box.space.test:drop()
os.exit()

How to run:

$ tarantool -i reproducer.lua

Actual output:

---
- [1, 2]
- [2, 2]
- [10000, 10000]

Actual behavior

Duplicates appear in secondary index.

Expected behavior

No duplicates occur in secondary index ({1, 2} rolls back with ER_CONFLICTED error).

Metadata

Metadata

Assignees

Labels

3.2Target is 3.2 and all newer release/master branchesbugSomething isn't workingmvcc

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions