Commit a8b8544a authored by Jan Lindström's avatar Jan Lindström

MDEV-7906: InnoDB: Failing assertion: prebuilt->sql_stat_start || trx->state...

MDEV-7906: InnoDB: Failing assertion: prebuilt->sql_stat_start || trx->state == 1 on concurrent multi-table update

Analysis: Problem is that SQL-layer calls handler API after storage
engine has already returned error state. InnoDB does internal
rollback when it notices transaction error (e.g. lock wait timeout,
deadlock, etc.) and after this transaction is not naturally in
correct state to continue.

Fix: Do not continue fetch operations if transaction is not started.
parent c79e98e4
...@@ -93,7 +93,6 @@ extern "C" { ...@@ -93,7 +93,6 @@ extern "C" {
#include "ibuf0ibuf.h" #include "ibuf0ibuf.h"
enum_tx_isolation thd_get_trx_isolation(const THD* thd); enum_tx_isolation thd_get_trx_isolation(const THD* thd);
} }
#include "ha_innodb.h" #include "ha_innodb.h"
...@@ -6299,6 +6298,11 @@ ha_innobase::general_fetch( ...@@ -6299,6 +6298,11 @@ ha_innobase::general_fetch(
DBUG_ENTER("general_fetch"); DBUG_ENTER("general_fetch");
/* If transaction is not startted do not continue, instead return a error code. */
if(!(prebuilt->sql_stat_start || (prebuilt->trx && prebuilt->trx->conc_state == 1))) {
DBUG_RETURN(HA_ERR_END_OF_FILE);
}
ut_a(prebuilt->trx == thd_to_trx(user_thd)); ut_a(prebuilt->trx == thd_to_trx(user_thd));
innodb_srv_conc_enter_innodb(prebuilt->trx); innodb_srv_conc_enter_innodb(prebuilt->trx);
......
...@@ -102,7 +102,6 @@ extern "C" { ...@@ -102,7 +102,6 @@ extern "C" {
#include "ibuf0ibuf.h" #include "ibuf0ibuf.h"
enum_tx_isolation thd_get_trx_isolation(const THD* thd); enum_tx_isolation thd_get_trx_isolation(const THD* thd);
} }
#include "ha_innodb.h" #include "ha_innodb.h"
...@@ -7327,6 +7326,11 @@ ha_innobase::general_fetch( ...@@ -7327,6 +7326,11 @@ ha_innobase::general_fetch(
DBUG_ENTER("general_fetch"); DBUG_ENTER("general_fetch");
/* If transaction is not startted do not continue, instead return a error code. */
if(!(prebuilt->sql_stat_start || (prebuilt->trx && prebuilt->trx->state == 1))) {
DBUG_RETURN(HA_ERR_END_OF_FILE);
}
if (UNIV_UNLIKELY(share->ib_table->is_corrupt && if (UNIV_UNLIKELY(share->ib_table->is_corrupt &&
srv_pass_corrupt_table <= 1)) { srv_pass_corrupt_table <= 1)) {
DBUG_RETURN(HA_ERR_CRASHED); DBUG_RETURN(HA_ERR_CRASHED);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment