Skip to content

Commit ff9150f

Browse files
committed
MDEV-25942: Assertion failure in trx_t::drop_table()
trx_t::drop_table(): Relax also another assertion that would fail due to an AUTO_INCREMENT lock that is being held by the current test case. This should have been part of commit 63e9a05.
1 parent c2ebe81 commit ff9150f

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

mysql-test/suite/innodb/r/lock_insert_into_empty.result

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,18 @@ REPLACE INTO t1 VALUES (1,12);
3737
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`f`) REFERENCES `nonexistent` (`x`))
3838
COMMIT;
3939
DROP TABLE t1;
40+
#
41+
# MDEV-25942 Assertion failed in trx_t::drop_table()
42+
#
43+
CREATE TABLE t1 (k INT PRIMARY KEY) ENGINE=InnoDB;
44+
INSERT INTO t1 SET k=1;
45+
START TRANSACTION;
46+
INSERT INTO t1 SET k=2;
47+
connect con1,localhost,root,,test;
48+
SET innodb_lock_wait_timeout= 1;
49+
CREATE TABLE t2 (pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB
50+
AS SELECT k FROM t1;
51+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
52+
disconnect con1;
53+
connection default;
54+
DROP TABLE t1;

mysql-test/suite/innodb/t/lock_insert_into_empty.test

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,22 @@ REPLACE INTO t1 VALUES (1,12);
3939
COMMIT;
4040

4141
DROP TABLE t1;
42+
43+
--echo #
44+
--echo # MDEV-25942 Assertion failed in trx_t::drop_table()
45+
--echo #
46+
47+
CREATE TABLE t1 (k INT PRIMARY KEY) ENGINE=InnoDB;
48+
INSERT INTO t1 SET k=1;
49+
START TRANSACTION;
50+
INSERT INTO t1 SET k=2;
51+
52+
--connect (con1,localhost,root,,test)
53+
SET innodb_lock_wait_timeout= 1;
54+
--error ER_LOCK_WAIT_TIMEOUT
55+
CREATE TABLE t2 (pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB
56+
AS SELECT k FROM t1;
57+
--disconnect con1
58+
--connection default
59+
60+
DROP TABLE t1;

storage/innobase/dict/drop.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,16 @@ dberr_t trx_t::drop_table(const dict_table_t &table)
159159
lock= UT_LIST_GET_NEXT(un_member.tab_lock.locks, lock))
160160
{
161161
ut_ad(lock->trx == this);
162-
if (lock->type_mode == (LOCK_X | LOCK_TABLE))
162+
switch (lock->type_mode) {
163+
case LOCK_TABLE | LOCK_X:
163164
found_x= true;
164-
else
165-
ut_ad(lock->type_mode == (LOCK_IX | LOCK_TABLE));
165+
break;
166+
case LOCK_TABLE | LOCK_IX:
167+
case LOCK_TABLE | LOCK_AUTO_INC:
168+
break;
169+
default:
170+
ut_ad("unexpected lock type" == 0);
171+
}
166172
}
167173
ut_ad(found_x);
168174
#endif

0 commit comments

Comments
 (0)