Bug #100971 EXCHANGE PARTITION assert
Submitted: 28 Sep 2020 6:14 Modified: 12 Oct 2020 20:48
Reporter: songlei wang Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Partitions Severity:S7 (Test Cases)
Version:8.0.21 OS:CentOS
Assigned to: CPU Architecture:Any

[28 Sep 2020 6:14] songlei wang
Description:
The statement 'ALTER TABLE t1 EXCHANGE PARTITION p201412 WITH TABLE t2' will cause an assert if t1 is not a partition table. 

How to repeat:
The 1exchange.test is as follows:

CREATE TABLE t1 (
    LogTime TIMESTAMP NOT NULL DEFAULT '2000-01-01 00:00:00',
    UserAgent VARCHAR(256) COLLATE utf8_bin DEFAULT NULL,
    KEY IX_LogTime (LogTime)
) ENGINE=INNODB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
PARTITION BY RANGE(UNIX_TIMESTAMP(LogTime))
  (
   PARTITION p201407 VALUES LESS THAN (UNIX_TIMESTAMP('2014-08-01')),
   PARTITION p201412 VALUES LESS THAN (UNIX_TIMESTAMP('2015-01-01')),
   PARTITION p201501 VALUES LESS THAN (UNIX_TIMESTAMP('2015-02-01')),
   PARTITION p201502 VALUES LESS THAN (UNIX_TIMESTAMP('2015-03-01')),
   PARTITION p201503 VALUES LESS THAN (UNIX_TIMESTAMP('2015-04-01')),
   PARTITION future VALUES LESS THAN MAXVALUE
  );
SHOW CREATE TABLE t1;

CREATE TABLE t2 (
    LogTime TIMESTAMP NOT NULL DEFAULT '2000-01-01 00:00:00',
    UserAgent VARCHAR(256) COLLATE utf8_bin DEFAULT NULL,
    KEY IX_LogTime (LogTime)
) ENGINE=INNODB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
SHOW CREATE TABLE t2;

INSERT INTO t2 VALUES('2014-08-02 00:00:00','useragent');

ALTER TABLE t1 EXCHANGE PARTITION p201412 WITH TABLE t2;

Then run the command in debug version:
./mysql-test-run.pl  --report-unstable-tests --sanitize --timer --skip-ndb --nounit-tests --ps-protocol --parallel=1 1exchange

will cause the assert as follows:

../mysql-bin/M_8021/bin/mysqld(my_print_stacktrace(unsigned char const*, unsigned long)+0x43) [0x46092d7]
../mysql-bin/M_8021/bin/mysqld(handle_fatal_signal+0x299) [0x32c495a]
/lib64/libpthread.so.0(+0xf620) [0x7fc184cf8620]
/lib64/libc.so.6(gsignal+0x37) [0x7fc182f19277]
/lib64/libc.so.6(abort+0x148) [0x7fc182f1a968]
../mysql-bin/M_8021/bin/mysqld(ut_dbg_assertion_failed(char const*, char const*, unsigned long)+0x19a) [0x4a7bbd4]
../mysql-bin/M_8021/bin/mysqld(ha_innopart::exchange_partition_low(unsigned int, dd::Table*, dd::Table*)+0x10da) [0x47b4d7e]
../mysql-bin/M_8021/bin/mysqld(Partition_handler::exchange_partition(unsigned int, dd::Table*, dd::Table*)+0xab) [0x2f9ea1b]
../mysql-bin/M_8021/bin/mysqld(Sql_cmd_alter_table_exchange_partition::exchange_partition(THD*, TABLE_LIST*, Alter_info*)+0x8e9) [0x374dfe1]
../mysql-bin/M_8021/bin/mysqld(Sql_cmd_alter_table_exchange_partition::execute(THD*)+0x258) [0x374cdb8]
../mysql-bin/M_8021/bin/mysqld(mysql_execute_command(THD*, bool)+0x5cab) [0x30eaa70]
../mysql-bin/M_8021/bin/mysqld(mysql_parse(THD*, Parser_state*)+0x6bd) [0x30ed49e]
../mysql-bin/M_8021/bin/mysqld(dispatch_command(THD*, COM_DATA const*, enum_server_command)+0x1482) [0x30e2522]
../mysql-bin/M_8021/bin/mysqld(do_command(THD*)+0x482) [0x30e0a57]
../mysql-bin/M_8021/bin/mysqld() [0x32af03f]
../mysql-bin/M_8021/bin/mysqld() [0x4e297ad]
/lib64/libpthread.so.0(+0x7e25) [0x7fc184cf0e25]
/lib64/libc.so.6(clone+0x6d) [0x7fc182fe0f1d]
[28 Sep 2020 7:03] MySQL Verification Team
Hello songlei wang,

Thank you for the report.

regards,
Umesh
[28 Sep 2020 7:05] MySQL Verification Team
MySQL Server 8.0.21 test results

Attachment: 100971.results.txt (text/plain), 138.92 KiB.

[12 Oct 2020 20:48] Jon Stephens
Documented fix as follows in the MySQL 8.0.23 changelog:

    ALTER TABLE t1 EXCHANGE PARTITION ... WITH TABLE t2 led to an
    assert when t1 was not a partitioned table.

Closed.