-
Notifications
You must be signed in to change notification settings - Fork 35
storage: preserve original error on function fail #629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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)
949d8a9 to
80bd895
Compare
Serpentian
left a comment
There was a problem hiding this 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
Serpentian
left a comment
There was a problem hiding this 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
Serpentian
left a comment
There was a problem hiding this 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
Gerold103
left a comment
There was a problem hiding this 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 💪!
| 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', | ||
| {}) |
There was a problem hiding this comment.
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().
| if not func then | ||
| return pcall(netbox_self_call, netbox_self, func_name, args) | ||
| end |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
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