-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
driver: fix duplicate id error with mvvc on
Taking the maximum of the index is an implicit transactions, so it is always done with 'read-confirmed' mvcc isolation level. It can lead to errors when trying to make parallel 'put' calls with mvcc enabled. It is hapenning because 'max' for several puts in parallel will be the same since read confirmed isolation level makes visible all transactions that finished the commit. To fix it we wrap it with box.begin/commit and set right isolation level. Closes #207
- Loading branch information
1 parent
16e3b74
commit cb8b91f
Showing
5 changed files
with
174 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env tarantool | ||
local qc = require('queue.compat') | ||
if not qc.check_version({2, 6, 1}) then | ||
log.info('Tests skipped, tarantool version < 2.6.1') | ||
return | ||
end | ||
local yaml = require('yaml') | ||
local fiber = require('fiber') | ||
|
||
local test = require('tap').test() | ||
test:plan(6) | ||
|
||
local queue = require('queue') | ||
local state = require('queue.abstract.state') | ||
|
||
local tnt = require('t.tnt') | ||
tnt.cfg{memtx_use_mvcc_engine = true} | ||
|
||
local engine = 'memtx' | ||
|
||
test:ok(rawget(box, 'space'), 'box started') | ||
test:ok(queue, 'queue is loaded') | ||
|
||
local tube = queue.create_tube('test', 'fifo', { engine = engine }) | ||
test:ok(tube, 'test tube created') | ||
test:is(tube.name, 'test', 'tube.name') | ||
test:is(tube.type, 'fifo', 'tube.type') | ||
|
||
test:test('concurent take', function(test) | ||
test:plan(151) | ||
|
||
local channel = fiber.channel(1000) | ||
test:ok(channel, 'channel created') | ||
|
||
local res = {} | ||
for i = 1, 50 do | ||
fiber.create(function(i) | ||
local taken = tube:take(1) | ||
test:ok(taken, 'Task was taken ' .. i) | ||
table.insert(res, { taken }) | ||
channel:put(true) | ||
end, i) | ||
end | ||
|
||
fiber.sleep(.1) | ||
test:ok(tube:put(1), 'task 1 was put') | ||
|
||
for i = 2, 50 do | ||
fiber.create(function(i) | ||
test:ok(tube:put(i), 'task ' .. i .. ' was put') | ||
end, i) | ||
end | ||
fiber.sleep(.1) | ||
for i = 1, 50 do | ||
test:ok(channel:get(1 / i), 'take was done ' .. i) | ||
end | ||
end) | ||
|
||
|
||
tnt.finish() | ||
os.exit(test:check() and 0 or 1) | ||
-- vim: set ft=lua: |