Details
-
Bug
-
Status: Open (View Workflow)
-
Critical
-
Resolution: Unresolved
-
10.11, 11.4, 11.8, 12.3, 13.0, 13.1, 13.2
-
None
Description
Likely cause: older than MDEV-25292. CS 13.1.0 has it too, and it looks like it comes from commit 6aa9a552c213246d4db6cfce78c75fd4b7f32df5 (MDEV-24576, 10.6.1), in create_table_impl().
--source include/have_innodb.inc
|
--source include/have_partition.inc
|
--source include/have_sequence.inc
|
|
|
CREATE TABLE t0 (a INT) ENGINE=InnoDB; |
INSERT INTO t0 SELECT seq FROM seq_1_to_3000000; |
CREATE TABLE t1 (b INT) ENGINE=InnoDB PARTITION BY HASH (b) PARTITIONS 2; |
INSERT INTO t1 VALUES (10),(20); |
|
|
--connect (con1,localhost,root,,test)
|
--send CREATE OR REPLACE TABLE t1 (a INT) ENGINE=InnoDB PARTITION BY HASH (a) PARTITIONS 2 SELECT a FROM t0
|
|
|
--connection default
|
--let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.PROCESSLIST WHERE INFO LIKE 'CREATE OR REPLACE%' AND TIME >= 1
|
--source include/wait_condition.inc
|
--source include/kill_mysqld.inc
|
--disconnect con1
|
--source include/start_mysqld.inc
|
|
|
--let $rows= query_get_value(SELECT COUNT(*) AS c FROM t1, c, 1)
|
if ($rows != 2) |
{
|
--die t1 has $rows rows after the restart, expected the 2 rows of the old table |
}
|
--echo t1 has the 2 rows of the old table
|
DROP TABLE t1, t0; |
Leads to:
|
MDEV-25292 CS 13.2.0 82964737c007bafad28cd45829874eb98593127a (Optimized, Clang 22.1.8-20260622) Build 16/10/2026 |
mysqltest: At line 23: t1 has 0 rows after the restart, expected the 2 rows of the old table
|
|
MDEV-25292 CS 13.2.0 82964737c007bafad28cd45829874eb98593127a (Debug, Clang 22.1.8-20260622) Build 16/10/2026 |
mariadbd: /test/MDEV-25292_main_dbg/storage/innobase/row/row0mysql.cc:2678: dberr_t row_rename_table_for_mysql(const char *, const char *, trx_t *, rename_fk): Assertion `err != DB_DUPLICATE_KEY' failed.
|
|
MDEV-25292 CS 13.2.0 82964737c007bafad28cd45829874eb98593127a (Debug, Clang 22.1.8-20260622) Build 16/10/2026 |
Core was generated by `/tmp/MDEV-25292_MD161026-mariadb-13.2.0-linux-x86_64-dbg/bin/mariadbd --default'.
|
Program terminated with signal SIGABRT, Aborted.
|
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44
|
|
|
[Current thread is 1 (LWP 2672677)]
|
(gdb) bt
|
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44
|
#1 __pthread_kill_internal (signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:78
|
#2 __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6)at ./nptl/pthread_kill.c:89
|
#3 0x00007a445504527e in __GI_raise (sig=sig@entry=6)at ../sysdeps/posix/raise.c:26
|
#4 0x00007a44550288ff in __GI_abort () at ./stdlib/abort.c:79
|
#5 0x00007a445502881b in __assert_fail_base (fmt=0x7a44551d1208 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x556b3f6a8583 "err != DB_DUPLICATE_KEY", file=file@entry=0x556b3f6a782a "/test/MDEV-25292_main_dbg/storage/innobase/row/row0mysql.cc", line=line@entry=2678, function=function@entry=0x556b3f6a8411 "dberr_t row_rename_table_for_mysql(const char *, const char *, trx_t *, rename_fk)") at ./assert/assert.c:96
|
#6 0x00007a445503b517 in __assert_fail (assertion=0x556b3f6a8583 "err != DB_DUPLICATE_KEY", file=0x556b3f6a782a "/test/MDEV-25292_main_dbg/storage/innobase/row/row0mysql.cc", line=2678, function=0x556b3f6a8411 "dberr_t row_rename_table_for_mysql(const char *, const char *, trx_t *, rename_fk)") at ./assert/assert.c:105
|
#7 0x0000556b3eeda570 in row_rename_table_for_mysql (old_name=0x7fffc2bc2ca0 "test/#sql-create-2885d2-5-0#P#p0", new_name=0x7fffc2bc2ea0 "test/t1#P#p0", trx=0x7a444fc00680, fk=RENAME_ALTER_COPY)at /test/MDEV-25292_main_dbg/storage/innobase/row/row0mysql.cc:2678
|
#8 0x0000556b3ece974a in innobase_rename_table (trx=0x7a444fc00680, from=0x7fffc2bc3dd0 "./test/#sql-create-2885d2-5-0#P#p0", to=0x7fffc2bc3bc0 "./test/t1#P#p0", fk=RENAME_ALTER_COPY)at /test/MDEV-25292_main_dbg/storage/innobase/handler/ha_innodb.cc:14098
|
#9 0x0000556b3ece9fba in ha_innobase::rename_table (this=0x556b52ff5420, from=0x7fffc2bc3dd0 "./test/#sql-create-2885d2-5-0#P#p0", to=0x7fffc2bc3bc0 "./test/t1#P#p0")at /test/MDEV-25292_main_dbg/storage/innobase/handler/ha_innodb.cc:14538
|
#10 0x0000556b3e8fc902 in handler::ha_rename_table (this=0x556b52ff5420, from=0x7fffc2bc3dd0 "./test/#sql-create-2885d2-5-0#P#p0", to=0x7fffc2bc3bc0 "./test/t1#P#p0")at /test/MDEV-25292_main_dbg/sql/handler.cc:6218
|
#11 0x0000556b3ec509d2 in ha_partition::del_ren_table (this=0x556b52ff4410, from=0x7fffc2bc4df0 "./test/#sql-create-2885d2-5-0", to=0x7fffc2bc5000 "./test/t1")at /test/MDEV-25292_main_dbg/sql/ha_partition.cc:2524
|
#12 0x0000556b3ec50d25 in ha_partition::rename_table (this=0x556b52ff4410, from=0x7fffc2bc4df0 "./test/#sql-create-2885d2-5-0", to=0x7fffc2bc5000 "./test/t1")at /test/MDEV-25292_main_dbg/sql/ha_partition.cc:686
|
#13 0x0000556b3e8fc902 in handler::ha_rename_table (this=0x556b52ff4410, from=0x7fffc2bc4df0 "./test/#sql-create-2885d2-5-0", to=0x7fffc2bc5000 "./test/t1")at /test/MDEV-25292_main_dbg/sql/handler.cc:6218
|
#14 0x0000556b3e62962d in execute_rename_table (thd=0x556b52ff8710, ddl_log_entry=0x7fffc2bc5280, file=0x556b52ff4410, from_db=0x7fffc2bc52b0, from_table=0x7fffc2bc5280, to_db=0x7fffc2bc52c0, to_table=0x7fffc2bc5290, flags=1, from_path=0x7fffc2bc4df0 "./test/#sql-create-2885d2-5-0", to_path=0x7fffc2bc5000 "./test/t1")at /test/MDEV-25292_main_dbg/sql/ddl_log.cc:1187
|
#15 0x0000556b3e6266f3 in ddl_log_execute_action (thd=0x556b52ff8710, mem_root=0x7fffc2bc5230, ddl_log_entry=0x7fffc2bc5280)at /test/MDEV-25292_main_dbg/sql/ddl_log.cc:1632
|
#16 0x0000556b3e622e0b in ddl_log_execute_entry_no_lock (thd=0x556b52ff8710, first_entry=3) at /test/MDEV-25292_main_dbg/sql/ddl_log.cc:2608
|
#17 0x0000556b3e6233c2 in ddl_log_execute_recovery ()at /test/MDEV-25292_main_dbg/sql/ddl_log.cc:2991
|
#18 0x0000556b3e309c0c in init_server_components ()at /test/MDEV-25292_main_dbg/sql/mysqld.cc:6040
|
#19 0x0000556b3e3058c6 in mysqld_main (argc=163, argv=0x556b52b11d70)at /test/MDEV-25292_main_dbg/sql/mysqld.cc:6407
|
#20 0x0000556b3e302952 in main (argc=26, argv=0x7fffc2bc81a8)at /test/MDEV-25292_main_dbg/sql/main.cc:34
|
The server is killed while CREATE OR REPLACE copies the rows into the new t1. At the restart, the error log of the optimized build has [ERROR] DDL_LOG: Got error 1050 when trying to execute action for entry 1 of type 'rename table'. t1 is then empty, and the partitions of the old table stay in the data directory as #sql-create-27d3a2-5-0#P#p0.ibd and #sql-create-27d3a2-5-0#P#p1.ibd. The debug build hits the assertion during recovery, so the server does not start. Without the PARTITION BY clauses, t1 has its 2 rows after the restart.
From the code it seems that create_table_impl() in sql/sql_table.cc writes the DDL log entry for the new table with create_info->db_type, before mysql_create_frm_image() sets it to the partition engine. Recovery then asks InnoDB to drop test/t1, which InnoDB does not have, so the new partitions stay. The rename back of the old partitions then fails, because the new partitions still use the names t1#P#p0 and t1#P#p1.
The partitions left behind are older than the atomic CREATE OR REPLACE. On a CS 13.1.0 debug build, a crash at the ddl_log_create_before_binlog crash point during CREATE TABLE t1 (a INT) ENGINE=InnoDB PARTITION BY HASH (a) PARTITIONS 2 leaves t1#P#p0.ibd, t1#P#p1.ibd and t1.par. The same CREATE TABLE then fails with Table '`test`.`t1` /* Partition `p0` */' already exists.
Attachments
Issue Links
- is caused by
-
MDEV-24576 Atomic CREATE TABLE
-
- Closed
-
- relates to
-
MDEV-30883 Assertion `err != DB_DUPLICATE_KEY' failed in row_rename_table_for_mysql on ALTER TABLE
-
- Confirmed
-
-
MDEV-39181 [Draft] DDL_LOG: Got error 1696 when trying to execute action upon crash recovery
-
- Open
-
-
MDEV-25292 Atomic CREATE OR REPLACE TABLE
-
- Closed
-
-
MDEV-27180 Fully atomic partitioning DDL operations
-
- In Review
-