Skip to content

Conversation

@kamenkremen
Copy link
Contributor

@kamenkremen kamenkremen commented Dec 18, 2025

For older Tarantool versions vshard uses func.call to execute functions.

If such a function raises an error during an uncommitted transaction, 'Transaction is active...' error is going to be raised, which will mask the original error.

This patch fixes that bug by checking the function call result. If the function returns an error and a transaction is still active, vshard now explicitly rolls back the transaction.

Fixes #614
Fixes #630

NO_DOC=bugfix

Copy link
Collaborator

@Serpentian Serpentian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! I'm glad, you've figured out the reason 🎉

P.S. And please, don't forget to rebase)

@Serpentian Serpentian assigned kamenkremen and unassigned Serpentian Dec 22, 2025
@kamenkremen kamenkremen force-pushed the gh-614 branch 5 times, most recently from 949d8a9 to 80bd895 Compare December 26, 2025 23:26
Copy link
Collaborator

@Serpentian Serpentian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there! Well done

Copy link
Collaborator

@Serpentian Serpentian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nits are left

Copy link
Collaborator

@Serpentian Serpentian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the patches! Well done

Copy link
Collaborator

@Gerold103 Gerold103 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch 💪!

Comment on lines 704 to 716
local function test_local_call_return_type_consistency_template(add_to_schema,
g)
g.replica_1_a:exec(function(add_to_schema)
rawset(_G, 'test_return_tuple', function()
return box.tuple.new({100, 200, 'tuple'})
end)
if add_to_schema then
box.schema.func.create('test_return_tuple')
end
local status, result = ivshard.storage.call(1,
'read',
'test_return_tuple',
{})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The argument line wraps look malformed. Maybe make the function name shorter, or wrap all arguments to the next line like:


local function test_local_call_return_type_consistency_template(
    add_to_schema, g)
...

Same with the ivshard.storage.call().

Comment on lines 302 to 304
if not func then
return pcall(netbox_self_call, netbox_self, func_name, args)
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if my function left a transaction unfinished, and it was called via netbox_self_call(), then netbox_self_call() will roll it back?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. If the function throws an error during an active transaction, the transaction is rolled back in handle_eval_result. If the function leaves the transaction unfinished, it is rolled back after the function completes

In Tarantool versions prior to 3.0.0-beta1-18, `net_box.self.call()`
cannot invoke C stored or Lua persistent functions.
Therefore, if such a function is registered in `box.func`, vshard
executes it via `func.call` instead.

If such a function raises an error during an uncommitted transaction,
'Transaction is active...' error is going to be raised, which will mask
the original error.

This patch fixes that bug by checking the function call result. If the
function returns an error and a transaction is still active, vshard now
explicitly rolls back the transaction.

Additionally, this patch fixes inconsistent return types. Previously,
functions registered in the schema returned raw cdata (such as tuples),
while other functions returned data converted via msgpack. This patch
ensures consistency by performing a msgpack conversion for registered
functions as well.

Fixes tarantool#614
Fixes tarantool#630

NO_DOC=bugfix
@Serpentian Serpentian added the do not merge Not ready to be merged label Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge Not ready to be merged

Projects

None yet

3 participants