Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-25119

Test case for former ER_TABLE_EXISTS_ERROR or Assertion `err != DB_DUPLICATE_KEY' upon ALTER with FK and partitioning

    XMLWordPrintable

Details

    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
      

      Attachments

        Issue Links

          Activity

            People

              nikitamalyavin Nikita Malyavin
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.