Skip to content

{Replace, {in, up}sert} after selecting the same key with memtx transaction manager enabled causes transaction to self-conflict #7235

@CuriousGeorgiy

Description

@CuriousGeorgiy

Bug description
Consider the following fair assertion:

diff --git a/src/box/memtx_tx.c b/src/box/memtx_tx.c
index 74814cfbe..d32128e6d 100644
--- a/src/box/memtx_tx.c
+++ b/src/box/memtx_tx.c
@@ -543,6 +543,7 @@ memtx_tx_abort_all_for_ddl(struct txn *ddl_owner)
 int
 memtx_tx_cause_conflict(struct txn *breaker, struct txn *victim)
 {
+       assert(breaker != victim);
        struct tx_conflict_tracker *tracker = NULL;
        struct rlist *r1 = breaker->conflict_list.next;
        struct rlist *r2 = victim->conflicted_by_list.next;

Steps to reproduce

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

local txn_proxy = require('txn_proxy')

box.cfg{memtx_use_mvcc_engine = true}

box.schema.space.create('s')
box.space.s:create_index('pk')

local tx = txn_proxy:new()

tx:begin()
tx('box.space.s:select{0}')
tx('box.space.s:replace{0}')
tx:commit()

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

local txn_proxy = require('txn_proxy')

box.cfg{memtx_use_mvcc_engine = true}

box.schema.space.create('s')
box.space.s:create_index('pk')

local tx = txn_proxy:new()

tx:begin()
tx('box.space.s:select{0}')
tx('box.space.s:insert{0}')
tx:commit()

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

local txn_proxy = require('txn_proxy')

box.cfg{memtx_use_mvcc_engine = true}

box.schema.space.create('s')
box.space.s:create_index('pk')

local tx = txn_proxy:new()

tx:begin()
tx('box.space.s:select{0}')
tx('box.space.s:upsert({0}, {{"=", 1, 0}})')
tx:commit()

os.exit()

Actual behavior

Assertion failed: (breaker != victim), function memtx_tx_cause_conflict, file memtx_tx.c, line 546.

Expected behavior
Script successfully exits.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions