You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug#16041903 CONTINUE HANDLER NOT INVOKED IN A STORED
FUNCTION AFTER A LOCK WAIT TIMEOUT
Overview
--------
When the SQL layer is executing a sub statement (stored
function or trigger), some errors cannot be safely recovered
until we leave sub statement mode. This is the case for
e.g. ER_LOCK_WAIT_TIMEOUT. When this error is caught, the
handler does a callback to "mark_transaction_for_rollback()"
in the SQL layer, which makes the transaction be rolled back
implicitly. In "mark_transaction_for_rollback()", the flag
"THD::is_fatal_sub_stmt_error" is set. This flag is used to
effectievly disable the execution of a condition handler in
a stored function while handling the error. The flag is
reset when leaving sub statement mode, in
"restore_sub_statement_state()", if leaving the last level
of sub statements (i.e., nested sub statements are handled
by keeping the value of the flag when going to the previous
"stack frame").
The problem here is that the flag is set in
"mark_transaction_for_rollback()" even if the SQL layer is
not in sub statement mode. If this happens, and the
transaction afterwards calls a stored function with a
condition handler, the handler will be disabled since the
flag is already set when calling the function.
Suggested fix
-------------
The suggested fix is to set "is_fatal_sub_stmt_error"
in "mark_transaction_for_rollback()" only in the case where
the SQL layer is currently executing a sub statement
("in_sub_stmt==true"). If not in a sub statement,
setting the "is_fatal_sub_stmt_error" flag really has
no meaning. Additionally, when the flag is set when the SQL
layer is not actually in a sub statement, the flag is never
cleared since this happens only in
"THD::restore_sub_statement_state()" when leaving sub
statement mode.
0 commit comments