-
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)
| local err_msg = tostring(err) | ||
| t.assert_str_contains(err_msg, 'test_error') | ||
| t.assert_not_str_contains(err_msg, 'Transaction is active') | ||
| 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.
The cluster should be in the same state, as it was before test start, so, please, drop the func at the end:
box.schema.func.drop('test_fail')We should also drop the variables from _G at the end
| test_group.test_error_msg_is_preserved = function(g) | ||
| g.replica_1_a:exec(function() | ||
| local vshard = require('vshard') | ||
| local t = require('luatest') |
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.
We need neither vshard nor luatest, they're already defined in the https://github.com/tarantool/vshard/blob/master/test/instances/storage.lua and can be accessed via ivshard and ilt accordingly
| test_alerts_for_non_vshard_config_template(g, non_config_replica) | ||
| end | ||
|
|
||
| test_group.test_error_msg_is_preserved = function(g) |
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.
Let's make sure, that plain function, defined in the _G (and not defined in the box.schema.func) is also not affected by this problem (it always returns the original error, not Transaction is active...
P.S. You can use "templates" in order avoid code duplication, e.g:
vshard/test/router-luatest/router_2_2_test.lua
Lines 982 to 983 in 0c564c3
| failed_calls_affect_priority_template(vconsts.FAILOVER_DOWN_SEQUENTIAL_FAIL) | |
| failed_calls_affect_priority_template(1) |
| instance_name = 'named_replica' | ||
| } | ||
| }) | ||
|
|
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.
Nit: the commit msg is a little bit misleading, I didn't manage to understand the problem from it:
For older Tarantool versions vshard uses func.call to execute functions.
Nah, we use custom local_call function for older versions, which uses func.call for functions defined in the box.schema.func and net.box.self.call for everything else
So, at the end only box.schema.func are affected by this problem?
| -- its original error will be masked by the 'Transaction is active...' | ||
| -- error, so we check function result manually and rollback the transaction | ||
| -- in case of an error. | ||
| local count, results = (function(...) |
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.
This one is really difficult to read, can we just copy-paste the handle_eval_result and use it as follows:
bc5d7d5 to
3b9b8c7
Compare
For older Tarantool versions vshard uses func.call to execute functions registered in schema. 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