1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-26772 InnoDB DDL fails with DUPLICATE KEY error

ha_innobase::delete_table(): When the table that is being dropped
has a name starting with #sql, temporarily set
innodb_lock_wait_timeout=0 while attempting to lock the
persistent statistics tables. If the statistics tables cannot be locked,
pretend that statistics did not exist and carry on with dropping
the table. The SQL layer is not really prepared for failures of
this operation. This is what fixes the test case.

ha_innobase::rename_table(): When renaming a table from a name
that starts with #sql, try to lock the statistics tables with an
immediate timeout, and ignore the statistics if the locks were
not available. In fact, during any rename from a #sql name,
dict_stats_rename_table() should have no effect, because already
when an earlier rename to a #sql name took place we should have
deleted the statistics for the table using the non-#sql name.
This change is just analogous to the ha_innobase::delete_table().
This commit is contained in:
Marko Mäkelä
2021-10-19 19:54:29 +03:00
parent f7684f0ca5
commit 6e390a62ba
3 changed files with 110 additions and 4 deletions

View File

@ -142,5 +142,42 @@ SET DEBUG_DBUG = @saved_debug_dbug;
DROP TABLE t;
--echo #
--echo # MDEV-26772 InnoDB DDL fails with DUPLICATE KEY error
--echo #
create table t1(f1 int not null primary key,
f2 int not null, index idx(f2))engine=innodb;
insert into t1 values(1, 1);
connect(con1,localhost,root,,,);
SET DEBUG_SYNC='before_delete_table_stats SIGNAL blocked WAIT_FOR go';
SET innodb_lock_wait_timeout=0;
send ALTER TABLE t1 FORCE, ALGORITHM=COPY;
connection default;
SET DEBUG_SYNC='now WAIT_FOR blocked';
BEGIN;
SELECT * FROM mysql.innodb_table_stats FOR UPDATE;
SET DEBUG_SYNC='now SIGNAL go';
connection con1;
reap;
connection default;
COMMIT;
SET DEBUG_SYNC=RESET;
connection con1;
ALTER TABLE t1 RENAME KEY idx TO idx1, ALGORITHM=COPY;
disconnect con1;
connection default;
DROP TABLE t1;
--echo # End of 10.6 tests
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc