forked from tarantool/tarantool
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
limbo: fix commit/rollback failures with triggers
Currently some transactions on synchronous space fail to complete with the `ER_CURSOR_NO_TRANSACTION` error, when on_rollback/on_commit triggers are set. This is caused due to the fact, that some rollback/commit triggers require in_txn fiber variable to be set but it's not done when a transaction is completed from the limbo. Callbacks, which are used to work with iterators (`lbox_txn_pairs` and `lbox_txn_iterator_next`), acquire tnx statements from the current transactions, but they cannot do that, when this transaction is not assigned to the current fiber, so `ER_CURSOR_NO_TRANSACTION` is thrown. Let's assign in_txn variable when we complete transaction from the limbo. Moreover, let's add assertions, which check whether in_txn() is correct, in order to be sure, that `txn_complete_success/fail` always run with in_txn set. Closes tarantool#8505 NO_DOC=bugfix
- Loading branch information
1 parent
116df1d
commit 6ff0b0c
Showing
4 changed files
with
93 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## bugfix/core | ||
|
||
* Fixed a bug causing the `ER_CURSOR_NO_TRANSACTION` failure for transactions | ||
on synchronous spaces when the `on_commit/on_rollback` triggers are set | ||
(gh-8505). |
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,67 @@ | ||
local t = require('luatest') | ||
local replica_set = require('luatest.replica_set') | ||
local server = require('luatest.server') | ||
|
||
local g = t.group('gh-8505-synchro-triggers') | ||
|
||
g.before_all(function(g) | ||
g.replica_set = replica_set:new({}) | ||
g.box_cfg = { | ||
replication_timeout = 0.01, | ||
replication = { | ||
server.build_listen_uri('server1', g.replica_set.id), | ||
server.build_listen_uri('server2', g.replica_set.id), | ||
}, | ||
} | ||
|
||
g.box_cfg.election_mode = 'voter' | ||
g.server2 = g.replica_set:build_and_add_server({ | ||
alias = 'server2', box_cfg = g.box_cfg | ||
}) | ||
|
||
g.box_cfg.election_mode = 'candidate' | ||
g.server1 = g.replica_set:build_and_add_server({ | ||
alias = 'server1', box_cfg = g.box_cfg | ||
}) | ||
|
||
g.replica_set:start() | ||
g.server1:wait_for_election_leader() | ||
g.server1:exec(function() | ||
box.schema.create_space('test', {is_sync = true}):create_index('pk') | ||
end) | ||
g.server2:wait_for_vclock_of(g.server1) | ||
end) | ||
|
||
g.after_all(function(g) | ||
g.replica_set:drop() | ||
end) | ||
|
||
g.test_on_commit_trigger = function(g) | ||
g.server1:exec(function() | ||
box.begin() | ||
box.on_commit(function(iter) iter() end) | ||
box.space.test:upsert({1}, {{'=', 1, 1}}) | ||
box.commit() | ||
end) | ||
end | ||
|
||
g.test_on_rollback_trigger = function(g) | ||
-- Force ACK gathering to fail and cause rollback | ||
local cfg = g.box_cfg | ||
cfg.replication_synchro_timeout = 1e-9 | ||
cfg.election_mode = 'candidate' | ||
|
||
g.server1:update_box_cfg(cfg) | ||
g.server1:wait_for_election_leader() | ||
|
||
g.server1:exec(function() | ||
box.begin() | ||
box.on_rollback(function(iter) iter() end) | ||
box.space.test:upsert({1}, {{'=', 1, 1}}) | ||
local _, err = pcall(box.commit) | ||
t.assert_equals(err.code, box.error.SYNC_QUORUM_TIMEOUT) | ||
end) | ||
|
||
g.server1:update_box_cfg(g.box_cfg) | ||
g.server1:wait_for_election_leader() | ||
end |