[MDEV-14642] Assertion `table->s->db_create_options == part_table->s->db_create_options' failed in compare_table_with_partition Created: 2017-12-13  Updated: 2022-05-18  Resolved: 2022-05-18

Status: Closed
Project: MariaDB Server
Component/s: Partitioning
Affects Version/s: 10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7
Fix Version/s: 10.3.36, 10.4.26, 10.5.17, 10.6.9, 10.7.5, 10.8.4, 10.9.2

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Nayuta Yanagisawa (Inactive)
Resolution: Fixed Votes: 0
Labels: upstream

Issue Links:
Relates
relates to MDEV-18858 Assertion `table->s->db_options_in_us... Confirmed
relates to MDEV-23357 Server crashes in Sql_cmd_alter_table... Closed

 Description   

--source include/have_partition.inc
 
CREATE TABLE t1 (i INT NOT NULL, KEY (i)) ROW_FORMAT=DYNAMIC PARTITION BY KEY(i) PARTITIONS 2;
CREATE TABLE t2 (i INT NOT NULL, KEY (i));
ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2;
 
# Cleanup
DROP TABLE t1, t2;

10.0 6559ba71a564

mysqld: /data/src/10.0/sql/sql_partition_admin.cc:238: bool compare_table_with_partition(THD*, TABLE*, TABLE*, partition_element*): Assertion `table->s->db_create_options == part_table->s->db_create_options' failed.
171214 12:43:46 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f738819cee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x00000000009c0dce in compare_table_with_partition (thd=0x7f73822a2070, table=0x7f738089f070, part_table=0x7f738089e470, part_elem=0x7f7380b87e68) at /data/src/10.0/sql/sql_partition_admin.cc:237
#9  0x00000000009c1c1a in Sql_cmd_alter_table_exchange_partition::exchange_partition (this=0x7f73808fadc8, thd=0x7f73822a2070, table_list=0x7f73808fa1a0, alter_info=0x7f738a26ba40) at /data/src/10.0/sql/sql_partition_admin.cc:590
#10 0x00000000009c07df in Sql_cmd_alter_table_exchange_partition::execute (this=0x7f73808fadc8, thd=0x7f73822a2070) at /data/src/10.0/sql/sql_partition_admin.cc:92
#11 0x000000000065398b in mysql_execute_command (thd=0x7f73822a2070) at /data/src/10.0/sql/sql_parse.cc:5114
#12 0x0000000000656dc2 in mysql_parse (thd=0x7f73822a2070, rawbuf=0x7f73808fa088 "ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2", length=50, parser_state=0x7f738a26c640) at /data/src/10.0/sql/sql_parse.cc:6569
#13 0x0000000000649901 in dispatch_command (command=COM_QUERY, thd=0x7f73822a2070, packet=0x7f73837e5071 "ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2", packet_length=50) at /data/src/10.0/sql/sql_parse.cc:1296
#14 0x0000000000648c01 in do_command (thd=0x7f73822a2070) at /data/src/10.0/sql/sql_parse.cc:999
#15 0x0000000000768ab8 in do_handle_one_connection (thd_arg=0x7f73822a2070) at /data/src/10.0/sql/sql_connect.cc:1377
#16 0x000000000076882a in handle_one_connection (arg=0x7f73822a2070) at /data/src/10.0/sql/sql_connect.cc:1292
#17 0x0000000000ac9564 in pfs_spawn_thread (arg=0x7f73821a2370) at /data/src/10.0/storage/perfschema/pfs.cc:1861
#18 0x00007f7389ea0494 in start_thread (arg=0x7f738a26d700) at pthread_create.c:333
#19 0x00007f738825993f in clone () from /lib/x86_64-linux-gnu/libc.so.6

Reproducible on 10.x and MySQL 5.6, 5.7, with InnoDB and MyISAM. Also filed as https://bugs.mysql.com/bug.php?id=88916



 Comments   
Comment by Alice Sherepa [ 2020-07-31 ]

still reproducible

10.5 c69520c9dfa6e4a26258842a1d35

mariadbd: /10.5/sql/sql_partition_admin.cc:263: bool compare_table_with_partition(THD*, TABLE*, TABLE*, partition_element*, uint): Assertion `table->s->db_create_options == part_table->s->db_create_options' failed.
200731 14:17:39 [ERROR] mysqld got signal 6 ;
 
Server version: 10.5.5-MariaDB-debug-log
 
linux/raise.c:51(__GI_raise)[0x7fd1a6b747bb]
stdlib/abort.c:81(__GI_abort)[0x7fd1a6b5f535]
intl/loadmsgcat.c:1177(_nl_load_domain)[0x7fd1a6b5f40f]
??:0(__assert_fail)[0x7fd1a6b6d102]
sql/sql_partition_admin.cc:264(compare_table_with_partition(THD*, TABLE*, TABLE*, partition_element*, unsigned int))[0x560ca6f9b632]
sql/sql_partition_admin.cc:630(Sql_cmd_alter_table_exchange_partition::exchange_partition(THD*, TABLE_LIST*, Alter_info*))[0x560ca6f97b0d]
sql/sql_partition_admin.cc:109(Sql_cmd_alter_table_exchange_partition::execute(THD*))[0x560ca6b8f64d]
sql/sql_parse.cc:5951(mysql_execute_command(THD*))[0x560ca6b9cc7c]
sql/sql_parse.cc:7993(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x560ca6b73b95]
sql/sql_parse.cc:1869(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x560ca6b704ad]
sql/sql_parse.cc:1347(do_command(THD*))[0x560ca6f946c6]
sql/sql_connect.cc:1410(do_handle_one_connection(CONNECT*, bool))[0x560ca6f94023]
sql/sql_connect.cc:1314(handle_one_connection)[0x560ca7c49886]
nptl/pthread_create.c:487(start_thread)[0x7fd1a762ffa3]
x86_64/clone.S:97(clone)[0x7fd1a6c364cf]
 
Query (0x62b0000382a8): ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2

Comment by Roel Van de Paar [ 2021-01-11 ]

Also ran into this one

SET SQL_MODE='';
CREATE TABLE t1 (a INT, b VARCHAR(55), PRIMARY KEY(a)) ENGINE=InnoDB PARTITION BY RANGE (a) (PARTITION p0 VALUES LESS THAN (10), PARTITION p1 VALUES LESS THAN (100), PARTITION p2 VALUES LESS THAN (1000));
CREATE TABLE t2 (a INT, b VARCHAR(55), PRIMARY KEY(a)) CHECKSUM=1, ENGINE=InnoDB;
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;

Leads to:

10.6.0 9118fd360a3da0bba521caf2a35c424968235ac4 (Debug)

mysqld: /test/10.6_dbg/sql/sql_partition_admin.cc:262: bool compare_table_with_partition(THD*, TABLE*, TABLE*, partition_element*, uint): Assertion `table->s->db_create_options == part_table->s->db_create_options' failed.

10.6.0 9118fd360a3da0bba521caf2a35c424968235ac4 (Debug)

Core was generated by `/test/MD010121-mariadb-10.6.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
    at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
[Current thread is 1 (Thread 0x149bd4097700 (LWP 1554364))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1  0x000056552d8b60d7 in my_write_core (sig=sig@entry=6) at /test/10.6_dbg/mysys/stacktrace.c:424
#2  0x000056552d04aab1 in handle_fatal_signal (sig=6) at /test/10.6_dbg/sql/signal_handler.cc:330
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#5  0x0000149bd626c859 in __GI_abort () at abort.c:79
#6  0x0000149bd626c729 in __assert_fail_base (fmt=0x149bd6402588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x56552da4c420 "table->s->db_create_options == part_table->s->db_create_options", file=0x56552da4c158 "/test/10.6_dbg/sql/sql_partition_admin.cc", line=262, function=<optimized out>) at assert.c:92
#7  0x0000149bd627df36 in __GI___assert_fail (assertion=assertion@entry=0x56552da4c420 "table->s->db_create_options == part_table->s->db_create_options", file=file@entry=0x56552da4c158 "/test/10.6_dbg/sql/sql_partition_admin.cc", line=line@entry=262, function=function@entry=0x56552da4c460 "bool compare_table_with_partition(THD*, TABLE*, TABLE*, partition_element*, uint)") at assert.c:101
#8  0x000056552cee2592 in compare_table_with_partition (part_id=0, part_elem=0x149b8403adc0, part_table=0x149b8401f428, table=0x149b840481f8, thd=0x149b84000db8) at /test/10.6_dbg/sql/sql_partition_admin.cc:262
#9  Sql_cmd_alter_table_exchange_partition::exchange_partition (this=this@entry=0x149b840135e0, thd=thd@entry=0x149b84000db8, table_list=<optimized out>, table_list@entry=0x149b840127d8, alter_info=alter_info@entry=0x149bd4095cc0) at /test/10.6_dbg/sql/sql_partition_admin.cc:630
#10 0x000056552cee2b75 in Sql_cmd_alter_table_exchange_partition::execute (this=0x149b840135e0, thd=0x149b84000db8) at /test/10.6_dbg/sql/sql_partition_admin.cc:109
#11 0x000056552cd8b4c6 in mysql_execute_command (thd=thd@entry=0x149b84000db8) at /test/10.6_dbg/sql/sql_parse.cc:5858
#12 0x000056552cd72072 in mysql_parse (thd=thd@entry=0x149b84000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x149bd40963d0) at /test/10.6_dbg/sql/sql_parse.cc:7881
#13 0x000056552cd801ec in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x149b84000db8, packet=packet@entry=0x149b84008d39 "ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2", packet_length=packet_length@entry=50) at /test/10.6_dbg/sql/sql_class.h:1293
#14 0x000056552cd8352d in do_command (thd=0x149b84000db8) at /test/10.6_dbg/sql/sql_parse.cc:1348
#15 0x000056552cedf7fc in do_handle_one_connection (connect=<optimized out>, connect@entry=0x56552f36ad98, put_in_cache=put_in_cache@entry=true) at /test/10.6_dbg/sql/sql_connect.cc:1410
#16 0x000056552cedff03 in handle_one_connection (arg=arg@entry=0x56552f36ad98) at /test/10.6_dbg/sql/sql_connect.cc:1312
#17 0x000056552d39588f in pfs_spawn_thread (arg=0x56552f2a5e08) at /test/10.6_dbg/storage/perfschema/pfs.cc:2201
#18 0x0000149bd677a609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#19 0x0000149bd6369293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.2.37 (dbg), 10.3.28 (dbg), 10.4.18 (dbg), 10.5.9 (dbg), 10.6.0 (dbg)
MySQL: 5.6.50 (dbg), 5.7.32 (dbg), 8.0.22 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.37 (opt), 10.3.28 (opt), 10.4.18 (opt), 10.5.9 (opt), 10.6.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.50 (opt), 5.7.32 (opt), 8.0.22 (opt)

Comment by Nayuta Yanagisawa (Inactive) [ 2022-05-14 ]

https://github.com/MariaDB/server/pull/2116

Comment by Nayuta Yanagisawa (Inactive) [ 2022-05-16 ]

The following test case passes. So, the problem seems to be MyISAM specific,.

--source include/have_partition.inc                                                                                                                                      
--source include/have_innodb.inc
 
CREATE TABLE t1 (i INT NOT NULL, KEY (i)) ENGINE=InnoDB ROW_FORMAT=REDUNDANT PARTITION BY KEY(i) PARTITIONS 2;
CREATE TABLE t2 (i INT NOT NULL, KEY (i)) ENGINE=InnoDB;
--error ER_PARTITION_EXCHANGE_DIFFERENT_OPTION
ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2;
 
# Cleanup
DROP TABLE t1, t2;

--source include/have_partition.inc
 
CREATE TABLE t1 (i INT NOT NULL, KEY (i)) ENGINE=Aria ROW_FORMAT=DYNAMIC PARTITION BY KEY(i) PARTITIONS 2;
CREATE TABLE t2 (i INT NOT NULL, KEY (i)) ENGINE=Aria;
--error ER_PARTITION_EXCHANGE_DIFFERENT_OPTION
ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2;
 
# Cleanup
DROP TABLE t1, t2;

This is because row formats of Aria or InnoDB tables are verified by the following code. MyISAM doesn't implement ha_myisam::get_row_type() and thus the verification doesn't work for MyISAM.

  /* Check compatible row_types and set create_info accordingly. */
  {
    enum row_type part_row_type= part_table->file->get_row_type();
    enum row_type table_row_type= table->file->get_row_type();
    if (part_row_type != table_row_type)
    {
      my_error(ER_PARTITION_EXCHANGE_DIFFERENT_OPTION, MYF(0),
               "ROW_FORMAT");
      DBUG_RETURN(true);
    }
    part_create_info.row_type= table->s->row_type;
  }

Comment by Nayuta Yanagisawa (Inactive) [ 2022-05-16 ]

A simplified version of the test case provided by roel:

--source include/have_partition.inc
--source include/have_innodb.inc
 
CREATE TABLE t1 (a INT, PRIMARY KEY(a)) ENGINE=InnoDB PARTITION BY KEY(a) PARTITIONS 2;
CREATE TABLE t2 (a INT, PRIMARY KEY(a)) CHECKSUM=1, ENGINE=InnoDB;
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
 
# Cleanup
DROP TABLE t1, t2;

Comment by Nayuta Yanagisawa (Inactive) [ 2022-05-16 ]

The following test cases are OK because ha_maria::check_if_incompatible_data() or ha_myisam::check_if_incompatible_data() detects the difference on the CHECKSUM option in mysql_compare_tables(). However, InnoDB and ha_innobase::check_if_incompatible_data() silently ignores the CHECKSUM option and it results in the assertion error.

--source include/have_partition.inc
 
CREATE TABLE t1 (a INT, PRIMARY KEY(a)) PARTITION BY KEY(a) PARTITIONS 2;
CREATE TABLE t2 (a INT, PRIMARY KEY(a)) CHECKSUM=1;
--error ER_TABLES_DIFFERENT_METADATA
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
 
# Cleanup
DROP TABLE t1, t2;

--source include/have_partition.inc
 
CREATE TABLE t1 (a INT, PRIMARY KEY(a)) ENGINE=Aria PARTITION BY KEY(a) PARTITIONS 2;
CREATE TABLE t2 (a INT, PRIMARY KEY(a)) CHECKSUM=1 ENGINE=Aria;
--error ER_TABLES_DIFFERENT_METADATA
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
 
# Cleanup
DROP TABLE t1, t2;

Comment by Nayuta Yanagisawa (Inactive) [ 2022-05-18 ]

Closed by https://github.com/MariaDB/server/commit/8881c0100e2131077410b360b27b7af30db56e1a

Generated at Thu Feb 08 08:15:10 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.