-
Praveenkumar.Hulakund authored
TRX_ROLLBACK_LAST_SQL_STAT_FOR_MYSQL Bug 20008555 - ASSERTION FAILURE IN TRX0TRX.CC LINE 1689 | ABORT SIG 6 IN TRX_MARK_SQL_STAT_END Issue here is, when transaction is in XA_PREPARE state, innodb transaction is registered for a "SELECT" query execution with the prepare state. Assert condition to check whether this transaction is in active state or not during commit and rollback operations are resulting in the issues reported in the bugs. In the open_tables function, we have check to verify transaction is in prepare or idle state. But this check is executed only when table_list is not empty. And this check is before getting the tables used by stored routines. So for the SELECT with only stored function call (e.g. SELECT f1()) this check is skipped as table_list is empty and while processing we add table used by routine to table_list. In "handle_query" function, lock_tables is called for the tables used in query. This in turn calls the ha_innobase::external_lock which registers a transaction with a prepare state. In the scenario mentioned in bug#19941492, while executing the stored function, the transaction state is checked in open_tables and error is returned. In this case, transaction is rolled back. Since transaction state is prepare instead of active, assert condition mentioned in the rollback code failed. In the scenario mentioned in bug#20008555, since system variable "sql_select_limit" is set to 0. Stored function is not executed, error related transaction state is not reported. So transaction is committed. Since transaction state is prepare instead of active, assert condition mentioned in the commit code failed. Fix: ------------ In open_tables function, check to avoid operations when transaction is in idle or prepare state and when any tables are used is very early. The check is before even processing tables used in stored routines. This is the route cause for both scenarios mentioned in the big report of 19941492 and 20008555. To fix this issue, moved check after preparing all the tables used in the query.
Praveenkumar.Hulakund authoredTRX_ROLLBACK_LAST_SQL_STAT_FOR_MYSQL Bug 20008555 - ASSERTION FAILURE IN TRX0TRX.CC LINE 1689 | ABORT SIG 6 IN TRX_MARK_SQL_STAT_END Issue here is, when transaction is in XA_PREPARE state, innodb transaction is registered for a "SELECT" query execution with the prepare state. Assert condition to check whether this transaction is in active state or not during commit and rollback operations are resulting in the issues reported in the bugs. In the open_tables function, we have check to verify transaction is in prepare or idle state. But this check is executed only when table_list is not empty. And this check is before getting the tables used by stored routines. So for the SELECT with only stored function call (e.g. SELECT f1()) this check is skipped as table_list is empty and while processing we add table used by routine to table_list. In "handle_query" function, lock_tables is called for the tables used in query. This in turn calls the ha_innobase::external_lock which registers a transaction with a prepare state. In the scenario mentioned in bug#19941492, while executing the stored function, the transaction state is checked in open_tables and error is returned. In this case, transaction is rolled back. Since transaction state is prepare instead of active, assert condition mentioned in the rollback code failed. In the scenario mentioned in bug#20008555, since system variable "sql_select_limit" is set to 0. Stored function is not executed, error related transaction state is not reported. So transaction is committed. Since transaction state is prepare instead of active, assert condition mentioned in the commit code failed. Fix: ------------ In open_tables function, check to avoid operations when transaction is in idle or prepare state and when any tables are used is very early. The check is before even processing tables used in stored routines. This is the route cause for both scenarios mentioned in the big report of 19941492 and 20008555. To fix this issue, moved check after preparing all the tables used in the query.
Loading