-
Notifications
You must be signed in to change notification settings - Fork 12
Closed
Description
If an error is thrown by the executed function while transaction is active, luatest.Server.exec returns a wrong error: "Transaction is active at return from function".
To reproduce the issue, add the following test to the Tarantool repository and run it:
local server = require('test.luatest_helpers.server')
local t = require('luatest')
local g = t.group()
g.before_all = function(cg)
cg.server = server:new({alias = 'master'})
cg.server:start()
end
g.after_all = function(cg)
cg.server:stop()
end
g.test_error_in_tx_net_box = function(cg)
local c = require('net.box').connect(cg.server.net_box_uri)
t.assert_error_msg_contains(
"My error", c.eval, c,
[[box.begin() error("My error")]])
end
g.test_error_in_tx_eval = function(cg)
t.assert_error_msg_contains(
"My error", cg.server.eval, cg.server,
[[box.begin() error("My error")]])
end
g.test_error_in_tx_exec = function(cg)
t.assert_error_msg_contains(
"My error", cg.server.exec, cg.server,
function() box.begin() error("My error") end)
endYou'll get:
$ luatest -v test/box-luatest/error_in_tx_test.lua
Running with --shuffle group:7246
Started on Fri Aug 26 11:10:58 2022
box-luatest.error_in_tx.test_error_in_tx_exec ... (0.001s) fail
...arantool/tarantool/test/box-luatest/error_in_tx_test.lua:28: Error message does not contain: "My error"
Error message received: "Transaction is active at return from function"
box-luatest.error_in_tx.test_error_in_tx_net_box ... (0.005s) Ok
box-luatest.error_in_tx.test_error_in_tx_eval ... (0.001s) Ok
=========================================================
Failed tests:
-------------
1) box-luatest.error_in_tx.test_error_in_tx_exec
...arantool/tarantool/test/box-luatest/error_in_tx_test.lua:28: Error message does not contain: "My error"
Error message received: "Transaction is active at return from function"
stack traceback:
...arantool/tarantool/test/box-luatest/error_in_tx_test.lua:28: in function 'box-luatest.error_in_tx.test_error_in_tx_exec'
...
[C]: in function 'xpcall'
Ran 3 tests in 0.232 seconds, 2 succeeded, 1 failed
=========================================================
Failed tests:
box-luatest.error_in_tx.test_error_in_tx_exec
Note, neither net.box.eval nor luatest.Server.eval is affected (probably fixed in tarantool/tarantool#7288).
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working