Skip to content

Commit a8b8544

Browse files
author
Jan Lindström
committed
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.
1 parent c79e98e commit a8b8544

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

storage/innobase/handler/ha_innodb.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ extern "C" {
9393
#include "ibuf0ibuf.h"
9494

9595
enum_tx_isolation thd_get_trx_isolation(const THD* thd);
96-
9796
}
9897

9998
#include "ha_innodb.h"
@@ -6299,6 +6298,11 @@ ha_innobase::general_fetch(
62996298

63006299
DBUG_ENTER("general_fetch");
63016300

6301+
/* If transaction is not startted do not continue, instead return a error code. */
6302+
if(!(prebuilt->sql_stat_start || (prebuilt->trx && prebuilt->trx->conc_state == 1))) {
6303+
DBUG_RETURN(HA_ERR_END_OF_FILE);
6304+
}
6305+
63026306
ut_a(prebuilt->trx == thd_to_trx(user_thd));
63036307

63046308
innodb_srv_conc_enter_innodb(prebuilt->trx);

storage/xtradb/handler/ha_innodb.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ extern "C" {
102102
#include "ibuf0ibuf.h"
103103

104104
enum_tx_isolation thd_get_trx_isolation(const THD* thd);
105-
106105
}
107106

108107
#include "ha_innodb.h"
@@ -7327,6 +7326,11 @@ ha_innobase::general_fetch(
73277326

73287327
DBUG_ENTER("general_fetch");
73297328

7329+
/* If transaction is not startted do not continue, instead return a error code. */
7330+
if(!(prebuilt->sql_stat_start || (prebuilt->trx && prebuilt->trx->state == 1))) {
7331+
DBUG_RETURN(HA_ERR_END_OF_FILE);
7332+
}
7333+
73307334
if (UNIV_UNLIKELY(share->ib_table->is_corrupt &&
73317335
srv_pass_corrupt_table <= 1)) {
73327336
DBUG_RETURN(HA_ERR_CRASHED);

0 commit comments

Comments
 (0)