Skip to content

Commit 3989d38

Browse files
MDEV-27006 Assertion `!lock_trx_has_sys_table_locks(trx)' failed in dberr_t row_discard_tablespace_for_mysql(dict_table_t*, trx_t*)
- InnoDB import operation fails when it tries to unlock data dictionary lock before releasing the lock on system tables.
1 parent ba4f8e3 commit 3989d38

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,11 @@ ALTER TABLE imp_t1 IMPORT TABLESPACE;
1010
ERROR HY000: Schema mismatch (ROW_FORMAT mismatch)
1111
DROP TABLE imp_t1, t1;
1212
SET GLOBAL innodb_checksum_algorithm=@save_innodb_checksum_algorithm;
13+
#
14+
# MDEV-27006 Assertion `!lock_trx_has_sys_table_locks(trx)' --echo # failed in dberr_t row_discard_tablespace_for_mysql
15+
# (dict_table_t*, trx_t*)
16+
CREATE TABLE t1 (c INT KEY) ENGINE=INNODB;
17+
CREATE TABLE t2 (c INT KEY,FOREIGN KEY(c) REFERENCES t1 (c)) ENGINE=INNODB;
18+
ALTER TABLE t1 DISCARD TABLESPACE;
19+
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
20+
DROP TABLE t2, t1;

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,12 @@ DROP TABLE imp_t1, t1;
1818
--remove_file $datadir/test/imp_t1.ibd
1919

2020
SET GLOBAL innodb_checksum_algorithm=@save_innodb_checksum_algorithm;
21+
22+
--echo #
23+
--echo # MDEV-27006 Assertion `!lock_trx_has_sys_table_locks(trx)' --echo # failed in dberr_t row_discard_tablespace_for_mysql
24+
--echo # (dict_table_t*, trx_t*)
25+
CREATE TABLE t1 (c INT KEY) ENGINE=INNODB;
26+
CREATE TABLE t2 (c INT KEY,FOREIGN KEY(c) REFERENCES t1 (c)) ENGINE=INNODB;
27+
--error ER_ROW_IS_REFERENCED_2
28+
ALTER TABLE t1 DISCARD TABLESPACE;
29+
DROP TABLE t2, t1;

storage/innobase/row/row0mysql.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,6 +2495,7 @@ dberr_t row_discard_tablespace_for_mysql(dict_table_t *table, trx_t *trx)
24952495
fts_optimize_add_table(table);
24962496
}
24972497
trx->rollback();
2498+
row_mysql_unlock_data_dictionary(trx);
24982499
return err;
24992500
}
25002501
}
@@ -2508,10 +2509,7 @@ dberr_t row_discard_tablespace_for_mysql(dict_table_t *table, trx_t *trx)
25082509

25092510
err= row_discard_tablespace_foreign_key_checks(trx, table);
25102511
if (err != DB_SUCCESS)
2511-
{
2512-
row_mysql_unlock_data_dictionary(trx);
25132512
goto rollback;
2514-
}
25152513

25162514
/* Note: The following cannot be rolled back. Rollback would see the
25172515
UPDATE of SYS_INDEXES.TABLE_ID as two operations: DELETE and INSERT.

0 commit comments

Comments
 (0)