Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions test/storage-luatest/storage_1_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -674,3 +674,28 @@ test_group.test_info_disable_consistency = function(g)
ilt.assert(res.is_enabled)
end, {global_cfg})
end

local function test_error_msg_is_preserved_template(g, add_to_schema)
g.replica_1_a:exec(function(add_to_schema)
rawset(_G, 'test_fail', function()
box.begin()
error('test_error')
end)
if add_to_schema then
box.schema.func.create('test_fail')
end
local status, err = ivshard.storage.call(1, 'read', 'test_fail', {})
ilt.assert_not(status)
ilt.assert_str_contains(err.message, 'test_error')
ilt.assert_not_str_contains(err.message, 'Transaction is active')
rawset(_G, 'test_fail', nil)
if add_to_schema then
box.schema.func.drop('test_fail')
end
end, {add_to_schema})
end

test_group.test_error_msg_is_preserved = function(g)
test_error_msg_is_preserved_template(g, false)
test_error_msg_is_preserved_template(g, true)
end
16 changes: 15 additions & 1 deletion vshard/storage/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,20 @@ else
end
end

--
-- If the function is called directly, fails, and leaves an uncommitted
-- transaction, the original error is replaced by the "Transaction is active"
-- error. We manually check if the function returned an error. If so, we
-- rollback the transaction to reveal the original error.
--
local function handle_results(status, ...)
Comment thread
Serpentian marked this conversation as resolved.
Comment thread
Gerold103 marked this conversation as resolved.
if not status then
box.rollback()
return status, box.error.new(box.error.PROC_LUA, (...))
Comment thread
Gerold103 marked this conversation as resolved.
end
return status, ...
end

--
-- Invoke a function on this instance. Arguments are unpacked into the function
-- as arguments.
Expand All @@ -284,7 +298,7 @@ local_call = function(func_name, args)
if not func then
return pcall(netbox_self_call, netbox_self, func_name, args)
end
Comment thread
Gerold103 marked this conversation as resolved.
return pcall(func.call, func, args)
return handle_results(pcall(func.call, func, args))
end

end
Expand Down
Loading