[MDEV-24610] Assertion `auto_increment_value' failed in ha_partition::info on INSERT into MEMORY table Created: 2021-01-18  Updated: 2023-11-28

Status: Confirmed
Project: MariaDB Server
Component/s: Partitioning, Storage Engine - Memory
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Major
Reporter: Roel Van de Paar Assignee: Alexey Botchkov
Resolution: Unresolved Votes: 0
Labels: upstream

Issue Links:
Relates
relates to MDEV-21007 Assertion `auto_increment_value' fail... Stalled
relates to MDEV-18244 Server crashes in ha_innobase::update... Closed

 Description   

SET SQL_MODE='';
CREATE TABLE t (c BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY) ENGINE=MEMORY;
INSERT INTO t VALUES ('-9e999999');
ALTER TABLE t PARTITION BY KEY();
INSERT t VALUES (1);

Leads to:

10.6.0 9118fd360a3da0bba521caf2a35c424968235ac4 (Debug)

mysqld: /test/10.6_dbg/sql/ha_partition.cc:8330: virtual int ha_partition::info(uint): Assertion `auto_increment_value' 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 0x15454c146700 (LWP 2550847))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1  0x0000563deaa820d7 in my_write_core (sig=sig@entry=6) at /test/10.6_dbg/mysys/stacktrace.c:424
#2  0x0000563dea216ab1 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  0x0000154562dc2859 in __GI_abort () at abort.c:79
#6  0x0000154562dc2729 in __assert_fail_base (fmt=0x154562f58588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x563deadee6ad "auto_increment_value", file=0x563deadea900 "/test/10.6_dbg/sql/ha_partition.cc", line=8330, function=<optimized out>) at assert.c:92
#7  0x0000154562dd3f36 in __GI___assert_fail (assertion=assertion@entry=0x563deadee6ad "auto_increment_value", file=file@entry=0x563deadea900 "/test/10.6_dbg/sql/ha_partition.cc", line=line@entry=8330, function=function@entry=0x563deadebe50 "virtual int ha_partition::info(uint)") at assert.c:101
#8  0x0000563dea5463a4 in ha_partition::info (this=0x15451c069ac0, flag=64) at /test/10.6_dbg/sql/ha_partition.cc:8330
#9  0x0000563dea557415 in ha_partition::update_next_auto_inc_val (this=this@entry=0x15451c069ac0) at /test/10.6_dbg/sql/ha_partition.cc:10538
#10 0x0000563dea5574c2 in ha_partition::write_row (this=0x15451c069ac0, buf=0x15451c023a88 "\377\001") at /test/10.6_dbg/sql/ha_partition.cc:4397
#11 0x0000563dea22ae67 in handler::ha_write_row (this=0x15451c069ac0, buf=0x15451c023a88 "\377\001") at /test/10.6_dbg/sql/handler.cc:7144
#12 0x0000563de9f002ea in write_record (thd=thd@entry=0x15451c000db8, table=table@entry=0x15451c068dc8, info=info@entry=0x15454c144c60, sink=sink@entry=0x0) at /test/10.6_dbg/sql/sql_insert.cc:2104
#13 0x0000563de9f0c9a5 in mysql_insert (thd=thd@entry=0x15451c000db8, table_list=0x15451c012798, fields=@0x15451c005e28: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x563deb51b0e0 <end_of_list>, last = 0x15451c005e28, elements = 0}, <No data fields>}, values_list=@0x15451c005e70: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x15451c0133a0, last = 0x15451c0133a0, elements = 1}, <No data fields>}, update_fields=@0x15451c005e58: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x563deb51b0e0 <end_of_list>, last = 0x15451c005e58, elements = 0}, <No data fields>}, update_values=@0x15451c005e40: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x563deb51b0e0 <end_of_list>, last = 0x15451c005e40, elements = 0}, <No data fields>}, duplic=DUP_ERROR, ignore=false, result=0x0) at /test/10.6_dbg/sql/sql_insert.cc:1099
#14 0x0000563de9f5362d in mysql_execute_command (thd=thd@entry=0x15451c000db8) at /test/10.6_dbg/sql/sql_parse.cc:4439
#15 0x0000563de9f3e072 in mysql_parse (thd=thd@entry=0x15451c000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x15454c1453d0) at /test/10.6_dbg/sql/sql_parse.cc:7881
#16 0x0000563de9f4c1ec in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x15451c000db8, packet=packet@entry=0x15451c008d39 "INSERT t VALUES (1)", packet_length=packet_length@entry=19) at /test/10.6_dbg/sql/sql_class.h:1293
#17 0x0000563de9f4f52d in do_command (thd=0x15451c000db8) at /test/10.6_dbg/sql/sql_parse.cc:1348
#18 0x0000563dea0ab7fc in do_handle_one_connection (connect=<optimized out>, connect@entry=0x563dec5526e8, put_in_cache=put_in_cache@entry=true) at /test/10.6_dbg/sql/sql_connect.cc:1410
#19 0x0000563dea0abf03 in handle_one_connection (arg=arg@entry=0x563dec5526e8) at /test/10.6_dbg/sql/sql_connect.cc:1312
#20 0x0000563dea56188f in pfs_spawn_thread (arg=0x563dec47a718) at /test/10.6_dbg/storage/perfschema/pfs.cc:2201
#21 0x00001545632d0609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#22 0x0000154562ebf293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

10.2.37 (Debug)

mysqld: /test/10.2_dbg/sql/ha_partition.cc:6601: virtual int ha_partition::info(uint): Assertion `auto_increment_value' failed.

10.2.37 (Debug)

Core was generated by `/test/MD010121-mariadb-10.2.37-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 0x153cb8156700 (LWP 2592432))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1  0x0000563391ae9c2a in my_write_core (sig=sig@entry=6) at /test/10.2_dbg/mysys/stacktrace.c:382
#2  0x00005633913dc82b in handle_fatal_signal (sig=6) at /test/10.2_dbg/sql/signal_handler.cc:343
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#5  0x0000153cd1842859 in __GI_abort () at abort.c:79
#6  0x0000153cd1842729 in __assert_fail_base (fmt=0x153cd19d8588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x563391d54d82 "auto_increment_value", file=0x563391d55640 "/test/10.2_dbg/sql/ha_partition.cc", line=6601, function=<optimized out>) at assert.c:92
#7  0x0000153cd1853f36 in __GI___assert_fail (assertion=assertion@entry=0x563391d54d82 "auto_increment_value", file=file@entry=0x563391d55640 "/test/10.2_dbg/sql/ha_partition.cc", line=line@entry=6601, function=function@entry=0x563391d56558 "virtual int ha_partition::info(uint)") at assert.c:101
#8  0x0000563391a81f53 in ha_partition::info (this=0x153c640255a8, flag=64) at /test/10.2_dbg/sql/ha_partition.cc:6608
#9  0x0000563391a87b48 in ha_partition::write_row (this=0x153c640255a8, buf=0x153c64023c70 "\377\001") at /test/10.2_dbg/sql/ha_partition.cc:4147
#10 0x00005633913eabc6 in handler::ha_write_row (this=0x153c640255a8, buf=0x153c64023c70 "\377\001") at /test/10.2_dbg/sql/handler.cc:6116
#11 0x00005633911b2623 in write_record (thd=thd@entry=0x153c64000d90, table=table@entry=0x153c640249a0, info=info@entry=0x153cb8153ce0) at /test/10.2_dbg/sql/sql_insert.cc:1939
#12 0x00005633911bdbba in mysql_insert (thd=thd@entry=0x153c64000d90, table_list=0x153c64011268, fields=@0x153c640056b8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x5633922e4b20 <end_of_list>, last = 0x153c640056b8, elements = 0}, <No data fields>}, values_list=@0x153c64005700: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x153c64011948, last = 0x153c64011948, elements = 1}, <No data fields>}, update_fields=@0x153c640056e8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x5633922e4b20 <end_of_list>, last = 0x153c640056e8, elements = 0}, <No data fields>}, update_values=@0x153c640056d0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x5633922e4b20 <end_of_list>, last = 0x153c640056d0, elements = 0}, <No data fields>}, duplic=DUP_ERROR, ignore=false) at /test/10.2_dbg/sql/sql_insert.cc:1066
#13 0x00005633911d6558 in mysql_execute_command (thd=thd@entry=0x153c64000d90) at /test/10.2_dbg/sql/sql_parse.cc:4193
#14 0x00005633911dcea0 in mysql_parse (thd=thd@entry=0x153c64000d90, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x153cb8155550, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.2_dbg/sql/sql_parse.cc:7762
#15 0x00005633911df9d9 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x153c64000d90, packet=packet@entry=0x153c640195d1 "INSERT t VALUES (1)", packet_length=packet_length@entry=19, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.2_dbg/sql/sql_class.h:1096
#16 0x00005633911e27e1 in do_command (thd=0x153c64000d90) at /test/10.2_dbg/sql/sql_parse.cc:1381
#17 0x00005633912e7a61 in do_handle_one_connection (connect=connect@entry=0x5633952e5350) at /test/10.2_dbg/sql/sql_connect.cc:1336
#18 0x00005633912e7c8c in handle_one_connection (arg=0x5633952e5350) at /test/10.2_dbg/sql/sql_connect.cc:1241
#19 0x0000153cd1d48609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#20 0x0000153cd193f293 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.5.62 (dbg), 5.6.50 (dbg), 5.7.32 (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 (opt), 5.6.50 (opt), 5.7.32 (opt), 8.0.22 (dbg), 8.0.22 (opt)



 Comments   
Comment by Roel Van de Paar [ 2021-01-18 ]

Unique ID's across all versions (different stacks)

auto_increment_value|SIGABRT|ha_partition::info|ha_partition::update_next_auto_inc_val|ha_partition::write_row|handler::ha_write_row  # MD 10.3+
auto_increment_value|SIGABRT|ha_partition::info|ha_partition::write_row|handler::ha_write_row|write_record  # MD 10.2 + MS 5.5/5.6
auto_increment_value|SIGABRT|ha_partition::initialize_auto_increment|Partition_helper::set_auto_increment_if_higher|Partition_helper::ph_write_row|ha_partition::write_row  # MS 5.7

Comment by Elena Stepanova [ 2021-01-18 ]

Likely the same as MDEV-21007

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

Possibly, not sure.

Comment by Roel Van de Paar [ 2022-09-20 ]

Additional testcase leading to somewhat different stack

INSTALL PLUGIN Spider SONAME 'ha_spider.so';
CREATE USER Spider@localhost IDENTIFIED BY 'PWD123';
CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET '../socket.sock', DATABASE 'test', USER 'Spider', PASSWORD 'PWD123');
CREATE TABLE t (c INT);
CREATE OR REPLACE TABLE t1 (pk INT PRIMARY KEY) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv", TABLE "t"' WITH SYSTEM VERSIONING PARTITION BY KEY() PARTITIONS 3;
INSERT INTO t1 (c1) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
ALTER TABLE t1 REMOVE PARTITIONING;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, c2 tinyINT(1) UNSIGNED DEFAULT NULL, c3 VARCHAR(300) DEFAULT NULL, c4 INT(10) UNSIGNED NOT NULL, c5 INT(10) UNSIGNED DEFAULT NULL, PRIMARY KEY(c1)) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv", TABLE "t"' COMMENT='TABLE "st"' PARTITION BY LIST COLUMNS (c1) (PARTITION p1 DEFAULT COMMENT='srv "d"' ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv", TABLE "t"');
SELECT c1,c2,COUNT(*),MAX(c3) FROM t1 WHERE c1='y' OR c2='#C2' GROUP BY c1,c2 HAVING COUNT(*)=3;
SHOW CREATE TABLE t1;

Leads to:

10.11.0 6ebdd3013a18b01dbecec76b870810329eb76586 (Debug)

mysqld: /test/10.11_dbg/sql/ha_partition.cc:8545: virtual int ha_partition::info(uint): Assertion `auto_increment_value' failed.

10.11.0 6ebdd3013a18b01dbecec76b870810329eb76586 (Debug)

Core was generated by `/test/MD190922-mariadb-10.11.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
[Current thread is 1 (Thread 0x146efbb67700 (LWP 3754919))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x0000146f33f31859 in __GI_abort () at abort.c:79
#2  0x0000146f33f31729 in __assert_fail_base (fmt=0x146f340c7588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55eea6f6f402 "auto_increment_value", file=0x55eea6f6fcd8 "/test/10.11_dbg/sql/ha_partition.cc", line=8545, function=<optimized out>) at assert.c:92
#3  0x0000146f33f42fd6 in __GI___assert_fail (assertion=assertion@entry=0x55eea6f6f402 "auto_increment_value", file=file@entry=0x55eea6f6fcd8 "/test/10.11_dbg/sql/ha_partition.cc", line=line@entry=8545, function=function@entry=0x55eea6f70aa8 "virtual int ha_partition::info(uint)") at assert.c:101
#4  0x000055eea671a61d in ha_partition::info (this=this@entry=0x146ee40d7280, flag=flag@entry=64) at /test/10.11_dbg/sql/ha_partition.cc:8545
#5  0x000055eea671ac5f in ha_partition::update_create_info (this=0x146ee40d7280, create_info=0x146efbb63c20) at /test/10.11_dbg/sql/ha_partition.cc:2286
#6  0x000055eea621cd2b in add_table_options (thd=thd@entry=0x146ee4000d48, table=table@entry=0x146ee4055038, create_info_arg=create_info_arg@entry=0x0, schema_table=<optimized out>, sequence=sequence@entry=false, packet=packet@entry=0x146efbb64d40) at /test/10.11_dbg/sql/sql_show.cc:1868
#7  0x000055eea6220149 in show_create_table_ex (thd=thd@entry=0x146ee4000d48, table_list=table_list@entry=0x146ee40132d0, force_db=<optimized out>, force_db@entry=0x0, force_name=<optimized out>, force_name@entry=0x0, packet=packet@entry=0x146efbb64d40, create_info_arg=create_info_arg@entry=0x0, with_db_name=WITHOUT_DB_NAME) at /test/10.11_dbg/sql/sql_show.cc:2459
#8  0x000055eea6220474 in show_create_table (thd=thd@entry=0x146ee4000d48, table_list=table_list@entry=0x146ee40132d0, packet=packet@entry=0x146efbb64d40, create_info_arg=create_info_arg@entry=0x0, with_db_name=with_db_name@entry=WITHOUT_DB_NAME) at /test/10.11_dbg/sql/sql_show.cc:2029
#9  0x000055eea6220ee7 in mysqld_show_create_get_fields (thd=thd@entry=0x146ee4000d48, table_list=<optimized out>, table_list@entry=0x146ee40132d0, field_list=field_list@entry=0x146efbb64d20, buffer=buffer@entry=0x146efbb64d40) at /test/10.11_dbg/sql/sql_show.cc:2676
#10 0x000055eea6221e70 in mysqld_show_create (thd=thd@entry=0x146ee4000d48, table_list=table_list@entry=0x146ee40132d0) at /test/10.11_dbg/sql/sql_show.cc:1323
#11 0x000055eea617e270 in mysql_execute_command (thd=thd@entry=0x146ee4000d48, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.11_dbg/sql/sql_parse.cc:4368
#12 0x000055eea616b03c in mysql_parse (thd=thd@entry=0x146ee4000d48, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x146efbb66330) at /test/10.11_dbg/sql/sql_parse.cc:8037
#13 0x000055eea617866d in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x146ee4000d48, packet=packet@entry=0x146ee400aed9 "SHOW CREATE TABLE t1", packet_length=packet_length@entry=20, blocking=blocking@entry=true) at /test/10.11_dbg/sql/sql_class.h:1345
#14 0x000055eea617ad97 in do_command (thd=0x146ee4000d48, blocking=blocking@entry=true) at /test/10.11_dbg/sql/sql_parse.cc:1407
#15 0x000055eea62defb9 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55eea93f37a8, put_in_cache=put_in_cache@entry=true) at /test/10.11_dbg/sql/sql_connect.cc:1416
#16 0x000055eea62df4c3 in handle_one_connection (arg=0x55eea93f37a8) at /test/10.11_dbg/sql/sql_connect.cc:1318
#17 0x0000146f34442609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#18 0x0000146f3402e133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.4.27 (dbg), 10.5.18 (dbg), 10.6.10 (dbg), 10.7.6 (dbg), 10.8.5 (dbg), 10.9.3 (dbg), 10.10.2 (dbg), 10.11.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.4.27 (opt), 10.5.18 (opt), 10.6.10 (opt), 10.7.6 (opt), 10.8.5 (opt), 10.9.3 (opt), 10.10.2 (opt), 10.11.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.38 (dbg), 5.7.38 (opt), 8.0.29 (dbg), 8.0.29 (opt)

New unique ID's seen with this testcase are

auto_increment_value|SIGABRT|ha_partition::info|ha_partition::update_create_info|add_table_options|show_create_table
auto_increment_value|SIGABRT|ha_partition::info|ha_partition::update_create_info|add_table_options|show_create_table_ex

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