summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2021-11-09 18:08:12 +0530
committerThirunarayanan Balathandayuthapani <thiru@mariadb.com>2021-11-09 18:08:12 +0530
commit3989d3800d328bf84b922fe527890cf68eb1c138 (patch)
treefcddeb92642641c1631460a618e8a281c9d712d4
parentba4f8e317de33330c882b5de14979685a0216ce0 (diff)
downloadmariadb-git-3989d3800d328bf84b922fe527890cf68eb1c138.tar.gz
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.
-rw-r--r--mysql-test/suite/innodb/r/import_bugs.result8
-rw-r--r--mysql-test/suite/innodb/t/import_bugs.test9
-rw-r--r--storage/innobase/row/row0mysql.cc4
3 files changed, 18 insertions, 3 deletions
diff --git a/mysql-test/suite/innodb/r/import_bugs.result b/mysql-test/suite/innodb/r/import_bugs.result
index a52fe6abbd6..14e4954e79f 100644
--- a/mysql-test/suite/innodb/r/import_bugs.result
+++ b/mysql-test/suite/innodb/r/import_bugs.result
@@ -10,3 +10,11 @@ ALTER TABLE imp_t1 IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (ROW_FORMAT mismatch)
DROP TABLE imp_t1, t1;
SET GLOBAL innodb_checksum_algorithm=@save_innodb_checksum_algorithm;
+#
+# MDEV-27006 Assertion `!lock_trx_has_sys_table_locks(trx)' --echo # failed in dberr_t row_discard_tablespace_for_mysql
+# (dict_table_t*, trx_t*)
+CREATE TABLE t1 (c INT KEY) ENGINE=INNODB;
+CREATE TABLE t2 (c INT KEY,FOREIGN KEY(c) REFERENCES t1 (c)) ENGINE=INNODB;
+ALTER TABLE t1 DISCARD TABLESPACE;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
+DROP TABLE t2, t1;
diff --git a/mysql-test/suite/innodb/t/import_bugs.test b/mysql-test/suite/innodb/t/import_bugs.test
index 4b5c04e3056..9898d11fc80 100644
--- a/mysql-test/suite/innodb/t/import_bugs.test
+++ b/mysql-test/suite/innodb/t/import_bugs.test
@@ -18,3 +18,12 @@ DROP TABLE imp_t1, t1;
--remove_file $datadir/test/imp_t1.ibd
SET GLOBAL innodb_checksum_algorithm=@save_innodb_checksum_algorithm;
+
+--echo #
+--echo # MDEV-27006 Assertion `!lock_trx_has_sys_table_locks(trx)' --echo # failed in dberr_t row_discard_tablespace_for_mysql
+--echo # (dict_table_t*, trx_t*)
+CREATE TABLE t1 (c INT KEY) ENGINE=INNODB;
+CREATE TABLE t2 (c INT KEY,FOREIGN KEY(c) REFERENCES t1 (c)) ENGINE=INNODB;
+--error ER_ROW_IS_REFERENCED_2
+ALTER TABLE t1 DISCARD TABLESPACE;
+DROP TABLE t2, t1;
diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc
index 3defc0dbeac..746d1a850b2 100644
--- a/storage/innobase/row/row0mysql.cc
+++ b/storage/innobase/row/row0mysql.cc
@@ -2495,6 +2495,7 @@ rollback:
fts_optimize_add_table(table);
}
trx->rollback();
+ row_mysql_unlock_data_dictionary(trx);
return err;
}
}
@@ -2508,10 +2509,7 @@ rollback:
err= row_discard_tablespace_foreign_key_checks(trx, table);
if (err != DB_SUCCESS)
- {
- row_mysql_unlock_data_dictionary(trx);
goto rollback;
- }
/* Note: The following cannot be rolled back. Rollback would see the
UPDATE of SYS_INDEXES.TABLE_ID as two operations: DELETE and INSERT.