diff options
-rw-r--r-- | mysql-test/suite/innodb/r/innodb-alter-debug.result | 10 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/innodb-alter-debug.test | 12 | ||||
-rw-r--r-- | storage/innobase/handler/handler0alter.cc | 2 | ||||
-rw-r--r-- | storage/innobase/lock/lock0lock.cc | 1 |
4 files changed, 25 insertions, 0 deletions
diff --git a/mysql-test/suite/innodb/r/innodb-alter-debug.result b/mysql-test/suite/innodb/r/innodb-alter-debug.result index 519283536d5..81fc67e55c7 100644 --- a/mysql-test/suite/innodb/r/innodb-alter-debug.result +++ b/mysql-test/suite/innodb/r/innodb-alter-debug.result @@ -132,4 +132,14 @@ ALTER TABLE t1 RENAME KEY idx TO idx1, ALGORITHM=COPY; disconnect con1; connection default; DROP TABLE t1; +# +# MDEV-26903 Assertion ctx->trx->state == TRX_STATE_ACTIVE on DROP INDEX +# +CREATE TABLE t1(a INT PRIMARY KEY, b INT, INDEX(b)) ENGINE=InnoDB; +SET @save_dbug=@@debug_dbug; +SET debug_dbug='+d,innodb_table_deadlock'; +ALTER TABLE t1 DROP INDEX b, ALGORITHM=INPLACE; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +SET debug_dbug=@save_dbug; +DROP TABLE t1; # End of 10.6 tests diff --git a/mysql-test/suite/innodb/t/innodb-alter-debug.test b/mysql-test/suite/innodb/t/innodb-alter-debug.test index 7af8e882724..1789ec294e4 100644 --- a/mysql-test/suite/innodb/t/innodb-alter-debug.test +++ b/mysql-test/suite/innodb/t/innodb-alter-debug.test @@ -177,6 +177,18 @@ disconnect con1; connection default; DROP TABLE t1; +--echo # +--echo # MDEV-26903 Assertion ctx->trx->state == TRX_STATE_ACTIVE on DROP INDEX +--echo # + +CREATE TABLE t1(a INT PRIMARY KEY, b INT, INDEX(b)) ENGINE=InnoDB; +SET @save_dbug=@@debug_dbug; +SET debug_dbug='+d,innodb_table_deadlock'; +--error ER_LOCK_DEADLOCK +ALTER TABLE t1 DROP INDEX b, ALGORITHM=INPLACE; +SET debug_dbug=@save_dbug; +DROP TABLE t1; + --echo # End of 10.6 tests # Wait till all disconnects are completed diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 4fc4751ff1c..adeaf87f7fe 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -8678,6 +8678,8 @@ inline bool rollback_inplace_alter_table(Alter_inplace_info *ha_alter_info, /* If we have not started a transaction yet, (almost) nothing has been or needs to be done. */ dict_sys.lock(SRW_LOCK_CALL); + else if (ctx->trx->state == TRX_STATE_NOT_STARTED) + goto free_and_exit; else if (ctx->new_table) { ut_ad(ctx->trx->state == TRX_STATE_ACTIVE); diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 234d215d1df..f088d0186bd 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -3433,6 +3433,7 @@ lock_table_other_has_incompatible( static dberr_t lock_table_low(dict_table_t *table, lock_mode mode, que_thr_t *thr, trx_t *trx) { + DBUG_EXECUTE_IF("innodb_table_deadlock", return DB_DEADLOCK;); lock_t *wait_for= lock_table_other_has_incompatible(trx, LOCK_WAIT, table, mode); dberr_t err= DB_SUCCESS; |