[MDEV-25119] Test case for former ER_TABLE_EXISTS_ERROR or Assertion `err != DB_DUPLICATE_KEY' upon ALTER with FK and partitioning Created: 2021-03-11  Updated: 2021-07-12

Status: Open
Project: MariaDB Server
Component/s: Data Definition - Alter Table, Partitioning, Storage Engine - InnoDB, Tests
Affects Version/s: 10.5, 10.6
Fix Version/s: 10.5

Type: Bug Priority: Minor
Reporter: Elena Stepanova Assignee: Nikita Malyavin
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-26127 Assertion `err != DB_DUPLICATE_KEY' f... Closed

 Description   

Recently a seemingly unrelated patch for MDEV-24422 (with extra changes) fixed the failure below. It appears to be a sensitive area, the outcome of this scenario changed several times in the past. I think it's worth adding an explicit regression test case for this already fixed failure. Unfortunately, the test below is non-deterministic. It fails nearly every time for me, but for the regression suite it needs to be synchronized or otherwise improved.

--source include/have_innodb.inc
--source include/have_partition.inc
 
call mtr.add_suppression("has or is referenced in foreign key constraints which are not compatible");
 
CREATE TABLE t1 (pk INT PRIMARY KEY, a INT) ENGINE=InnoDB PARTITION BY KEY(pk);
SET FOREIGN_KEY_CHECKS= OFF;
CREATE TABLE t2 (id INT PRIMARY KEY, FOREIGN KEY (id) REFERENCES t1 (a)) ENGINE=InnoDB;
ALTER TABLE t1 REMOVE PARTITIONING;
 
--connect (con1,localhost,root,,test)
--send
  ALTER TABLE t1 PARTITION BY HASH(pk);
 
--connection default
ALTER TABLE t2 FORCE;
ALTER TABLE t1 REMOVE PARTITIONING;
 
# Cleanup
--connection con1
--reap
--disconnect con1
--connection default
DROP TABLE t2, t1;

10.5 f6cb9e6e

mariadbd: /data/src/10.5/storage/innobase/row/row0mysql.cc:4339: dberr_t row_rename_table_for_mysql(const char*, const char*, trx_t*, bool, bool): Assertion `err != DB_DUPLICATE_KEY' failed.
210311 19:43:20 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f218e94cf36 in __GI___assert_fail (assertion=0x560314118775 "err != DB_DUPLICATE_KEY", file=0x560314115a28 "/data/src/10.5/storage/innobase/row/row0mysql.cc", line=4339, function=0x5603141185f8 "dberr_t row_rename_table_for_mysql(const char*, const char*, trx_t*, bool, bool)") at assert.c:101
#8  0x000056031396e9a6 in row_rename_table_for_mysql (old_name=0x7f21884f0f90 "test/#sql-alter-3829b5-4", new_name=0x7f21884f0d90 "test/t1", trx=0x7f2188fa24f8, commit=true, use_fk=true) at /data/src/10.5/storage/innobase/row/row0mysql.cc:4339
#9  0x00005603137d318f in innobase_rename_table (trx=0x7f2188fa24f8, from=0x7f21884f1f40 "./test/#sql-alter-3829b5-4", to=0x7f21884f2150 "./test/t1", commit=true, use_fk=true) at /data/src/10.5/storage/innobase/handler/ha_innodb.cc:13452
#10 0x00005603137ba681 in ha_innobase::rename_table (this=0x7f215c017330, from=0x7f21884f1f40 "./test/#sql-alter-3829b5-4", to=0x7f21884f2150 "./test/t1") at /data/src/10.5/storage/innobase/handler/ha_innodb.cc:13643
#11 0x0000560313337a4b in handler::ha_rename_table (this=0x7f215c017330, from=0x7f21884f1f40 "./test/#sql-alter-3829b5-4", to=0x7f21884f2150 "./test/t1") at /data/src/10.5/sql/handler.cc:4971
#12 0x00005603130ba72e in mysql_rename_table (base=0x560315530e68, old_db=0x7f21884f38e0, old_name=0x7f21884f3910, new_db=0x7f21884f38e0, new_name=0x7f21884f3900, flags=1) at /data/src/10.5/sql/sql_table.cc:5870
#13 0x00005603130c94ef in mysql_alter_table (thd=0x7f215c000db8, new_db=0x7f215c005808, new_name=0x7f215c005c08, create_info=0x7f21884f44b0, table_list=0x7f215c0153c0, alter_info=0x7f21884f43e0, order_num=0, order=0x0, ignore=false, if_exists=false) at /data/src/10.5/sql/sql_table.cc:10990
#14 0x00005603131709e4 in Sql_cmd_alter_table::execute (this=0x7f215c015a98, thd=0x7f215c000db8) at /data/src/10.5/sql/sql_alter.cc:539
#15 0x0000560312fc6f58 in mysql_execute_command (thd=0x7f215c000db8) at /data/src/10.5/sql/sql_parse.cc:6050
#16 0x0000560312fcd168 in mysql_parse (thd=0x7f215c000db8, rawbuf=0x7f215c0152d0 "ALTER TABLE t1 REMOVE PARTITIONING", length=34, parser_state=0x7f21884f5510, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:8089
#17 0x0000560312fb9043 in dispatch_command (command=COM_QUERY, thd=0x7f215c000db8, packet=0x7f215c00b589 "", packet_length=34, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:1889
#18 0x0000560312fb7837 in do_command (thd=0x7f215c000db8) at /data/src/10.5/sql/sql_parse.cc:1370
#19 0x0000560313165da7 in do_handle_one_connection (connect=0x560315a7d138, put_in_cache=true) at /data/src/10.5/sql/sql_connect.cc:1410
#20 0x0000560313165b0a in handle_one_connection (arg=0x560315b36778) at /data/src/10.5/sql/sql_connect.cc:1312
#21 0x00005603136c6adb in pfs_spawn_thread (arg=0x560315b73428) at /data/src/10.5/storage/perfschema/pfs.cc:2201
#22 0x00007f218ee64609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#23 0x00007f218ea38293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

10.5 f6cb9e6e non-debug

CURRENT_TEST: bug.10802a
mysqltest: At line 17: query 'ALTER TABLE t1 REMOVE PARTITIONING' failed: 1050: Table './test/t1' already exists



 Comments   
Comment by Elena Stepanova [ 2021-03-11 ]

I also suspect that a similar failure is possible on 10.3, and thus it remains unfixed there, but I don't have a test which would fail on 10.3 yet. In concurrent tests it's largely masked by MDEV-24545 and requires special actions for differentiating it from sequence-related problems.

Comment by Marko Mäkelä [ 2021-03-11 ]

The assertion was added by nikitamalyavin in 10.3.28, 10.4.18, 10.5.9.

Comment by Elena Stepanova [ 2021-03-11 ]

marko, the assertion is unimportant here, it's just an alternative representation (just like in MDEV-24545). The problem here is ER_TABLE_EXISTS_ERROR.

Generated at Thu Feb 08 09:35:17 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.