|
| 1 | +local server = require('test.luatest_helpers.server') |
| 2 | +local t = require('luatest') |
| 3 | + |
| 4 | +local g = t.group() |
| 5 | + |
| 6 | +g.before_all(function() |
| 7 | + g.server = server:new{ |
| 8 | + alias = 'dflt', |
| 9 | + box_cfg = {memtx_use_mvcc_engine = true} |
| 10 | + } |
| 11 | + g.server:start() |
| 12 | +end) |
| 13 | + |
| 14 | +g.after_all(function() |
| 15 | + g.server:drop() |
| 16 | +end) |
| 17 | + |
| 18 | +g.before_each(function() |
| 19 | + g.server:exec(function() |
| 20 | + local s = box.schema.space.create('s') |
| 21 | + s:create_index('pk', {parts = {{1, 'unsigned'}, |
| 22 | + {2, 'unsigned'}}}) |
| 23 | + s:insert{0, 0} |
| 24 | + s:insert{1, 0} |
| 25 | + end) |
| 26 | +end) |
| 27 | + |
| 28 | +g.after_each(function() |
| 29 | + g.server:eval('box.space.s:drop()') |
| 30 | +end) |
| 31 | + |
| 32 | +g['test_reverse_iter_gap_tracking'] = function() |
| 33 | + g.server:exec(function() |
| 34 | + local t = require('luatest') |
| 35 | + local txn_proxy = require('test.box.lua.txn_proxy') |
| 36 | + |
| 37 | + local tx = txn_proxy:new() |
| 38 | + |
| 39 | + local conflict_err = 'Transaction has been aborted by conflict' |
| 40 | + |
| 41 | + tx:begin() |
| 42 | + tx('box.space.s:select({1, 0}, {iterator = "LT"})') |
| 43 | + box.space.s:insert{0, 1} |
| 44 | + tx('box.space.s:insert{2, 0}') |
| 45 | + t.assert_equals(tx:commit(), {{error = conflict_err}}) |
| 46 | + box.space.s:delete{0, 1} |
| 47 | + |
| 48 | + tx:begin() |
| 49 | + tx('box.space.s:select({1, 0}, {iterator = "LE"})') |
| 50 | + box.space.s:insert{0, 1} |
| 51 | + tx('box.space.s:insert{2, 0}') |
| 52 | + t.assert_equals(tx:commit(), {{error = conflict_err}}) |
| 53 | + box.space.s:delete{0, 1} |
| 54 | + |
| 55 | + tx:begin() |
| 56 | + tx('box.space.s:select({1}, {iterator = "LT"})') |
| 57 | + box.space.s:insert{0, 1} |
| 58 | + tx('box.space.s:insert{2, 0}') |
| 59 | + t.assert_equals(tx:commit(), {{error = conflict_err}}) |
| 60 | + box.space.s:delete{0, 1} |
| 61 | + |
| 62 | + tx:begin() |
| 63 | + tx('box.space.s:select({1}, {iterator = "LE"})') |
| 64 | + box.space.s:insert{0, 1} |
| 65 | + tx('box.space.s:insert{2, 0}') |
| 66 | + t.assert_equals(tx:commit(), {{error = conflict_err}}) |
| 67 | + box.space.s:delete{0, 1} |
| 68 | + |
| 69 | + tx:begin() |
| 70 | + tx('box.space.s:select({0}, {iterator = "REQ"})') |
| 71 | + box.space.s:insert{0, 1} |
| 72 | + tx('box.space.s:insert{2, 0}') |
| 73 | + t.assert_equals(tx:commit(), {{error = conflict_err}}) |
| 74 | + box.space.s:delete{0, 1} |
| 75 | + |
| 76 | + tx:begin() |
| 77 | + tx('box.space.s:select({1}, {iterator = "REQ"})') |
| 78 | + box.space.s:insert{1, 1} |
| 79 | + tx('box.space.s:insert{2, 0}') |
| 80 | + t.assert_equals(tx:commit(), {{error = conflict_err}}) |
| 81 | + box.space.s:delete{1, 1} |
| 82 | + |
| 83 | + tx:begin() |
| 84 | + end) |
| 85 | +end |
| 86 | + |
| 87 | +g['test_reverse_iter_clarify_before_gap_tracking'] = function() |
| 88 | + g.server:exec(function() |
| 89 | + local t = require('luatest') |
| 90 | + local txn_proxy = require('test.box.lua.txn_proxy') |
| 91 | + |
| 92 | + local tx = txn_proxy:new() |
| 93 | + |
| 94 | + --[[ |
| 95 | + The following tests are a safety net for catching the buggy case |
| 96 | + when tuple clarification could be done after gap tracking |
| 97 | + (gh-7073). |
| 98 | + --]] |
| 99 | + box.internal.memtx_tx_gc(128) |
| 100 | + |
| 101 | + tx:begin() |
| 102 | + box.space.s:delete{0, 0} |
| 103 | + t.assert_equals(tx("box.space.s:select({1, 0}, {iterator = 'LT'})"), |
| 104 | + {{}}) |
| 105 | + tx:commit() |
| 106 | + box.space.s:insert{0, 0} |
| 107 | + |
| 108 | + tx:begin() |
| 109 | + box.space.s:delete{0, 0} |
| 110 | + t.assert_equals(tx("box.space.s:select({0, 0}, {iterator = 'LE'})"), |
| 111 | + {{}}) |
| 112 | + tx:commit() |
| 113 | + box.space.s:insert{0, 0} |
| 114 | + |
| 115 | + tx:begin() |
| 116 | + box.space.s:delete{0, 0} |
| 117 | + t.assert_equals(tx("box.space.s:select({1}, {iterator = 'LT'})"), |
| 118 | + {{}}) |
| 119 | + tx:commit() |
| 120 | + box.space.s:insert{0, 0} |
| 121 | + |
| 122 | + tx:begin() |
| 123 | + box.space.s:delete{0, 0} |
| 124 | + t.assert_equals(tx("box.space.s:select({0}, {iterator = 'LE'})"), |
| 125 | + {{}}) |
| 126 | + tx:commit() |
| 127 | + box.space.s:insert{0, 0} |
| 128 | + |
| 129 | + tx:begin() |
| 130 | + box.space.s:delete{0, 0} |
| 131 | + t.assert_equals(tx("box.space.s:select({0}, {iterator = 'REQ'})"), |
| 132 | + {{}}) |
| 133 | + tx:commit() |
| 134 | + box.space.s:insert{0, 0} |
| 135 | + end) |
| 136 | +end |
0 commit comments