diff --git a/src/box/vy_tx.c b/src/box/vy_tx.c index 76d184fbda836b26b464db038af77738f5afd4f3..56b9f29225dab7f1a8ea264dc7e4cd3e5403ec0b 100644 --- a/src/box/vy_tx.c +++ b/src/box/vy_tx.c @@ -717,10 +717,6 @@ vy_tx_prepare(struct vy_tx *tx) } assert(lsm->space_id == current_space_id); - /* Do not save statements that was overwritten by the same tx */ - if (v->is_overwritten || v->is_nop) - continue; - if (lsm->index_id > 0 && repsert == NULL && delete == NULL) { /* * This statement is for a secondary index, @@ -735,9 +731,12 @@ vy_tx_prepare(struct vy_tx *tx) * skip it for secondary indexes as well. */ v->is_overwritten = true; - continue; } + /* Do not save statements that was overwritten by the same tx */ + if (v->is_overwritten || v->is_nop) + continue; + enum iproto_type type = vy_stmt_type(v->entry.stmt); /* Optimize out INSERT + DELETE for the same key. */ diff --git a/test/vinyl/gh.result b/test/vinyl/gh.result index 76beab094eef4e4170560849cfa406f296a54827..78cb2a28d9f857d3676d52c1770d1bcdc15b54ed 100644 --- a/test/vinyl/gh.result +++ b/test/vinyl/gh.result @@ -718,3 +718,40 @@ while finished ~= 2 do fiber.sleep(0.01) end s:drop() --- ... +-- +-- gh-4294: assertion failure when deleting a no-op statement from +-- a secondary index write set. +-- +s = box.schema.space.create('test', {engine = 'vinyl'}) +--- +... +_ = s:create_index('pk') +--- +... +_ = s:create_index('sk', {parts = {2, 'unsigned'}}) +--- +... +s:replace{1, 1, 1} +--- +- [1, 1, 1] +... +box.begin() +--- +... +s:update(1, {{'+', 3, 1}}) +--- +- [1, 1, 2] +... +s:delete(1) +--- +... +box.commit() +--- +... +s:select() +--- +- [] +... +s:drop() +--- +... diff --git a/test/vinyl/gh.test.lua b/test/vinyl/gh.test.lua index 2044f6cc5aa22cddecbcff229e41dce557b8165f..9ad857981295cf90ca0e60800ab4f53cc83690e5 100644 --- a/test/vinyl/gh.test.lua +++ b/test/vinyl/gh.test.lua @@ -312,3 +312,18 @@ cont = false while finished ~= 2 do fiber.sleep(0.01) end s:drop() + +-- +-- gh-4294: assertion failure when deleting a no-op statement from +-- a secondary index write set. +-- +s = box.schema.space.create('test', {engine = 'vinyl'}) +_ = s:create_index('pk') +_ = s:create_index('sk', {parts = {2, 'unsigned'}}) +s:replace{1, 1, 1} +box.begin() +s:update(1, {{'+', 3, 1}}) +s:delete(1) +box.commit() +s:select() +s:drop()