Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Memtx MVCC does not respect collation-based and MsgPack equivalence classes #11292

@CuriousGeorgiy

Description

@CuriousGeorgiy

This code assumes that equivalence classes of keys are defined by the MsgPack encoding:

/** point_hole_item comparator. */
static int
point_hole_storage_equal(const struct point_hole_item *obj1,
const struct point_hole_item *obj2)
{
/* Canonical msgpack is comparable by memcmp. */
if (obj1->index_unique_id != obj2->index_unique_id ||
obj1->key_len != obj2->key_len)
return 1;
return memcmp(obj1->key, obj2->key, obj1->key_len) != 0;
}

However, this is not true for collation-based comparisons, and this is also not true for suboptimal MsgPack encodings (#9965).

Steps to reproduce

os.execute('rm -rf *.snap *.xlog *.vylog 512')

local log = require('log')
local txn_proxy = require('test.box.lua.txn_proxy')

box.cfg{memtx_use_mvcc_engine = true}

box.schema.space.create('s'):create_index('p')
box.schema.space.create('c'):create_index('p', {parts = {{1, 'str', collation = 'unicode_ci'}}})

local tx1 = txn_proxy:new()
local tx2 = txn_proxy:new()
local tx3 = txn_proxy:new()

tx1:begin()
tx2:begin()
tx3:begin()

log.info(tx1("box.space.c:get{'ЁлКа'}"))
log.info(tx1("box.space.s:insert{0}"))
log.info(tx2("box.space.c:get{'ЁЛКа'}"))
log.info(tx1("box.space.s:insert{1}"))
log.info(tx3("box.space.c:insert{'ёлка'}"))
log.info(tx3:commit())
log.info(tx1:commit())
log.info(tx2:commit())

os.exit()

Actual behavior
Only one of tx1 and tx2 gets conflicted.

Expected behavior
Both tx1 and tx2 get conflicted.

Metadata

Metadata

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions