Skip to content
Snippets Groups Projects
Commit f92473f3 authored by Vladislav Shpilevoy's avatar Vladislav Shpilevoy Committed by Konstantin Osipov
Browse files

test: vinyl secondary idx iterator skips changes of read keys

If a key is updated after a secondary index scan, but before a
primary index lookup, then ignore this update.

Closes #2442
parent f909b656
No related branches found
No related tags found
No related merge requests found
...@@ -3868,6 +3868,14 @@ vinyl_iterator_next(struct iterator *base, struct tuple **ret) ...@@ -3868,6 +3868,14 @@ vinyl_iterator_next(struct iterator *base, struct tuple **ret)
} }
if (it->index->id > 0) { if (it->index->id > 0) {
#ifndef NDEBUG
struct errinj *delay = errinj(ERRINJ_VY_DELAY_PK_LOOKUP,
ERRINJ_BOOL);
if (delay && delay->bparam) {
while (delay->bparam)
fiber_sleep(0.01);
}
#endif
/* Get the full tuple from the primary index. */ /* Get the full tuple from the primary index. */
if (vy_index_get(it->index->pk, it->tx, it->rv, if (vy_index_get(it->index->pk, it->tx, it->rv,
tuple, &tuple) != 0) tuple, &tuple) != 0)
......
...@@ -105,6 +105,7 @@ struct errinj { ...@@ -105,6 +105,7 @@ struct errinj {
_(ERRINJ_BUILD_SECONDARY, ERRINJ_INT, {.iparam = -1}) \ _(ERRINJ_BUILD_SECONDARY, ERRINJ_INT, {.iparam = -1}) \
_(ERRINJ_VY_POINT_ITER_WAIT, ERRINJ_BOOL, {.bparam = false}) \ _(ERRINJ_VY_POINT_ITER_WAIT, ERRINJ_BOOL, {.bparam = false}) \
_(ERRINJ_RELAY_EXIT_DELAY, ERRINJ_DOUBLE, {.dparam = 0}) \ _(ERRINJ_RELAY_EXIT_DELAY, ERRINJ_DOUBLE, {.dparam = 0}) \
_(ERRINJ_VY_DELAY_PK_LOOKUP, ERRINJ_BOOL, {.bparam = false}) \
ENUM0(errinj_id, ERRINJ_LIST); ENUM0(errinj_id, ERRINJ_LIST);
extern struct errinj errinjs[]; extern struct errinj errinjs[];
......
...@@ -30,6 +30,8 @@ errinj.info() ...@@ -30,6 +30,8 @@ errinj.info()
state: false state: false
ERRINJ_VYRUN_INDEX_GARBAGE: ERRINJ_VYRUN_INDEX_GARBAGE:
state: false state: false
ERRINJ_VY_DELAY_PK_LOOKUP:
state: false
ERRINJ_VY_TASK_COMPLETE: ERRINJ_VY_TASK_COMPLETE:
state: false state: false
ERRINJ_PORT_DUMP: ERRINJ_PORT_DUMP:
......
...@@ -1194,3 +1194,68 @@ box.commit() ...@@ -1194,3 +1194,68 @@ box.commit()
s:drop() s:drop()
--- ---
... ...
--
-- gh-2442: secondary index cursor must skip key update, made
-- after the secondary index scan, but before a primary index
-- lookup. It is ok, and the test checks this.
--
s = box.schema.create_space('test', {engine = 'vinyl'})
---
...
pk = s:create_index('pk')
---
...
sk = s:create_index('sk', {parts = {{2, 'unsigned'}}})
---
...
s:replace{1, 1}
---
- [1, 1]
...
s:replace{3, 3}
---
- [3, 3]
...
box.snapshot()
---
- ok
...
ret = nil
---
...
function do_read() ret = sk:select({2}, {iterator = 'GE'}) end
---
...
errinj.set("ERRINJ_VY_DELAY_PK_LOOKUP", true)
---
- ok
...
f = fiber.create(do_read)
---
...
f:status()
---
- suspended
...
ret
---
- null
...
s:replace{2, 2}
---
- [2, 2]
...
errinj.set("ERRINJ_VY_DELAY_PK_LOOKUP", false)
---
- ok
...
while ret == nil do fiber.sleep(0.01) end
---
...
ret
---
- - [3, 3]
...
s:drop()
---
...
...@@ -466,3 +466,26 @@ value ...@@ -466,3 +466,26 @@ value
box.commit() box.commit()
s:drop() s:drop()
--
-- gh-2442: secondary index cursor must skip key update, made
-- after the secondary index scan, but before a primary index
-- lookup. It is ok, and the test checks this.
--
s = box.schema.create_space('test', {engine = 'vinyl'})
pk = s:create_index('pk')
sk = s:create_index('sk', {parts = {{2, 'unsigned'}}})
s:replace{1, 1}
s:replace{3, 3}
box.snapshot()
ret = nil
function do_read() ret = sk:select({2}, {iterator = 'GE'}) end
errinj.set("ERRINJ_VY_DELAY_PK_LOOKUP", true)
f = fiber.create(do_read)
f:status()
ret
s:replace{2, 2}
errinj.set("ERRINJ_VY_DELAY_PK_LOOKUP", false)
while ret == nil do fiber.sleep(0.01) end
ret
s:drop()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment