[MDEV-21027] Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed in ha_partition::set_auto_increment_if_higher Created: 2019-11-11  Updated: 2022-12-07  Resolved: 2022-06-16

Status: Closed
Project: MariaDB Server
Component/s: Partitioning
Affects Version/s: 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9
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: not-10.2, regression

Issue Links:
Relates
relates to MDEV-21007 Assertion `auto_increment_value' fail... Stalled
relates to MDEV-21310 AUTO_INCREMENT column throws range er... Closed
relates to MDEV-29636 Assertion `part_share->auto_inc_initi... Closed

 Description   

--source include/have_partition.inc
 
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) PARTITION BY HASH (a) PARTITIONS 3;
REPLACE INTO t1 PARTITION (p0) VALUES (3),(8);
 
# Cleanup
DROP TABLE t1;

10.3 c4ee8a30

mysqld: /data/src/10.3/sql/ha_partition.h:1325: virtual void ha_partition::set_auto_increment_if_higher(Field*): Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed.
191111 16:17:15 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f16c2796f12 in __GI___assert_fail (assertion=0x55f18cc42d88 "part_share->auto_inc_initialized || !can_use_for_auto_inc_init()", file=0x55f18cc42d18 "/data/src/10.3/sql/ha_partition.h", line=1325, function=0x55f18cc48020 <ha_partition::set_auto_increment_if_higher(Field*)::__PRETTY_FUNCTION__> "virtual void ha_partition::set_auto_increment_if_higher(Field*)") at assert.c:101
#8  0x000055f18c7e9387 in ha_partition::set_auto_increment_if_higher (this=0x7f16ac0963f8, field=0x7f16ac1219c0) at /data/src/10.3/sql/ha_partition.h:1324
#9  0x000055f18c7d4fab in ha_partition::write_row (this=0x7f16ac0963f8, buf=0x7f16ac1219a0 "\377\003") at /data/src/10.3/sql/ha_partition.cc:4339
#10 0x000055f18bfba10c in handler::ha_write_row (this=0x7f16ac0963f8, buf=0x7f16ac1219a0 "\377\003") at /data/src/10.3/sql/handler.cc:6446
#11 0x000055f18bc520dc in write_record (thd=0x7f16ac000af0, table=0x7f16ac0957b0, info=0x7f16bc994bb0) at /data/src/10.3/sql/sql_insert.cc:1706
#12 0x000055f18bc50402 in mysql_insert (thd=0x7f16ac000af0, table_list=0x7f16ac012960, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_REPLACE, ignore=false) at /data/src/10.3/sql/sql_insert.cc:1072
#13 0x000055f18bc93ccb in mysql_execute_command (thd=0x7f16ac000af0) at /data/src/10.3/sql/sql_parse.cc:4455
#14 0x000055f18bc9f597 in mysql_parse (thd=0x7f16ac000af0, rawbuf=0x7f16ac012808 "REPLACE INTO t1 PARTITION (p0) VALUES (3),(8)", length=45, parser_state=0x7f16bc9955e0, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:7815
#15 0x000055f18bc8c11b in dispatch_command (command=COM_QUERY, thd=0x7f16ac000af0, packet=0x7f16ac008c61 "REPLACE INTO t1 PARTITION (p0) VALUES (3),(8)", packet_length=45, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1856
#16 0x000055f18bc8aa63 in do_command (thd=0x7f16ac000af0) at /data/src/10.3/sql/sql_parse.cc:1401
#17 0x000055f18be01bea in do_handle_one_connection (connect=0x55f18eb7a490) at /data/src/10.3/sql/sql_connect.cc:1403
#18 0x000055f18be0194c in handle_one_connection (arg=0x55f18eb7a490) at /data/src/10.3/sql/sql_connect.cc:1308
#19 0x000055f18c7b0718 in pfs_spawn_thread (arg=0x55f18eb95550) at /data/src/10.3/storage/perfschema/pfs.cc:1862
#20 0x00007f16c430c4a4 in start_thread (arg=0x7f16bc996700) at pthread_create.c:456
#21 0x00007f16c2853d0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97

Reproducible with at least InnoDB, MyISAM and Aria on 10.3-10.5.
Not reproducible on 10.2.

The failure appeared in 10.3 after this commit:

commit 6dce6aecebe6ef78a14cb5c5c5daa8a355551e40
Author: Alexey Botchkov <holyfoot@askmonty.org>
Date:   Fri Nov 1 09:39:43 2019 +0400
 
    MDEV-18244 Server crashes in ha_innobase::update_thd / ... / ha_partition::update_next_auto_inc_val.

Non-debug version returns an error (before and after the patch above):

CURRENT_TEST: bug.autoinc3
mysqltest: At line 4: query 'REPLACE INTO t1 PARTITION (p0) VALUES (3),(8)' failed: 1748: Found a row not matching the given partition set

which is probably expected.



 Comments   
Comment by Roel Van de Paar [ 2022-03-03 ]

Bug confirmed present in:
MariaDB: 10.3.35 (dbg), 10.4.25 (dbg), 10.6.8 (dbg), 10.7.4 (dbg), 10.8.3 (dbg), 10.9.0 (dbg)

Comment by Shunsuke Tokunaga [ 2022-05-20 ]

I made a PR: https://github.com/MariaDB/server/pull/2124
After it passes checks, could you please review it? @nayuta-yanagisawa

Comment by Alexey Botchkov [ 2022-06-12 ]

alternative fix proposal:
https://github.com/MariaDB/server/commit/7e058f88e57fbf4f8f19d99279821efe33cee78d

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