[MDEV-24808] Assertion `table_share->tmp_table != NO_TMP_TABLE || m_lock_type != 2' failed in handler::ha_index_read_map upon INSERT into partitioned table Created: 2021-02-08  Updated: 2023-11-28

Status: Confirmed
Project: MariaDB Server
Component/s: Partitioning
Affects Version/s: 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11, 11.0
Fix Version/s: 10.4, 10.5, 10.6, 10.11

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Yuchen Pei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

--source include/have_partition.inc
 
CREATE TABLE t1 (
  a INT NOT NULL AUTO_INCREMENT,
  UNIQUE (a) USING HASH
) ENGINE=MyISAM
PARTITION BY LIST (a) (
  PARTITION p0 VALUES IN (1,3),
  PARTITION p1 VALUES IN (8,4,2)
);
 
INSERT INTO t1 PARTITION (p1) (a) VALUES (8),(4);
 
# Cleanup
DROP TABLE t1;

10.4 debug 542d769e

mysqld: /data/src/10.4/sql/handler.cc:2918: int handler::ha_index_read_map(uchar*, const uchar*, key_part_map, ha_rkey_function): Assertion `table_share->tmp_table != NO_TMP_TABLE || m_lock_type != 2' failed.
210208 20:44:55 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f8baf45cf36 in __GI___assert_fail (assertion=0x556e58df10d8 "table_share->tmp_table != NO_TMP_TABLE || m_lock_type != 2", file=0x556e58defb01 "/data/src/10.4/sql/handler.cc", line=2918, function=0x556e58df1180 "int handler::ha_index_read_map(uchar*, const uchar*, key_part_map, ha_rkey_function)") at assert.c:101
#8  0x0000556e582c2549 in handler::ha_index_read_map (this=0x7f8b98042308, buf=0x7f8b981259c8 "\377\b", key=0x7f8ba942b71f "d\r", keypart_map=18446744073709551615, find_flag=HA_READ_KEY_EXACT) at /data/src/10.4/sql/handler.cc:2918
#9  0x0000556e58b284c8 in ha_partition::handle_unordered_scan_next_partition (this=0x7f8b981a8338, buf=0x7f8b981259c8 "\377\b") at /data/src/10.4/sql/ha_partition.cc:7457
#10 0x0000556e58b22e20 in ha_partition::common_index_read (this=0x7f8b981a8338, buf=0x7f8b981259c8 "\377\b", have_start_key=true) at /data/src/10.4/sql/ha_partition.cc:5713
#11 0x0000556e58b2298e in ha_partition::index_read_map (this=0x7f8b981a8338, buf=0x7f8b981259c8 "\377\b", key=0x7f8ba942b71f "d\r", keypart_map=18446744073709551615, find_flag=HA_READ_KEY_EXACT) at /data/src/10.4/sql/ha_partition.cc:5580
#12 0x0000556e582c26ba in handler::ha_index_read_map (this=0x7f8b981a8338, buf=0x7f8b981259c8 "\377\b", key=0x7f8ba942b71f "d\r", keypart_map=18446744073709551615, find_flag=HA_READ_KEY_EXACT) at /data/src/10.4/sql/handler.cc:2922
#13 0x0000556e582cd3ba in check_duplicate_long_entry_key (table=0x7f8b980414a0, h=0x7f8b981a8338, new_rec=0x7f8b981259c8 "\377\b", key_no=0) at /data/src/10.4/sql/handler.cc:6598
#14 0x0000556e582cda87 in check_duplicate_long_entries (table=0x7f8b980414a0, h=0x7f8b981a8338, new_rec=0x7f8b981259c8 "\377\b") at /data/src/10.4/sql/handler.cc:6670
#15 0x0000556e582cddd6 in handler::ha_write_row (this=0x7f8b981a8338, buf=0x7f8b981259c8 "\377\b") at /data/src/10.4/sql/handler.cc:6750
#16 0x0000556e57f06c0b in write_record (thd=0x7f8b98000d90, table=0x7f8b980414a0, info=0x7f8ba942ba70) at /data/src/10.4/sql/sql_insert.cc:2060
#17 0x0000556e57f03a75 in mysql_insert (thd=0x7f8b98000d90, table_list=0x7f8b980135b0, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false) at /data/src/10.4/sql/sql_insert.cc:1078
#18 0x0000556e57f52672 in mysql_execute_command (thd=0x7f8b98000d90) at /data/src/10.4/sql/sql_parse.cc:4571
#19 0x0000556e57f5e0ab in mysql_parse (thd=0x7f8b98000d90, rawbuf=0x7f8b98013458 "INSERT INTO t1 PARTITION (p1) (a) VALUES (8),(4)", length=48, parser_state=0x7f8ba942c550, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:7958
#20 0x0000556e57f4a3d3 in dispatch_command (command=COM_QUERY, thd=0x7f8b98000d90, packet=0x7f8b980087b1 "INSERT INTO t1 PARTITION (p1) (a) VALUES (8),(4)", packet_length=48, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1855
#21 0x0000556e57f48c3b in do_command (thd=0x7f8b98000d90) at /data/src/10.4/sql/sql_parse.cc:1373
#22 0x0000556e580d804b in do_handle_one_connection (connect=0x556e5a65fab0) at /data/src/10.4/sql/sql_connect.cc:1412
#23 0x0000556e580d7d94 in handle_one_connection (arg=0x556e5a65fab0) at /data/src/10.4/sql/sql_connect.cc:1316
#24 0x0000556e58af958c in pfs_spawn_thread (arg=0x556e5a5b24e0) at /data/src/10.4/storage/perfschema/pfs.cc:1869
#25 0x00007f8bafcdd609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#26 0x00007f8baf548293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Reproducible on 10.4-10.6 with at least InnoDB, MyISAM, Aria.
Not reproducible on 10.3.
No obvious immediate problem on a non-debug build.



 Comments   
Comment by Alice Sherepa [ 2023-04-19 ]

also on 11.0:

--source include/have_partition.inc
CREATE TABLE t1 ( a text , pk int NOT NULL auto_increment, UNIQUE KEY (a), KEY (pk)) PARTITION BY KEY (pk) PARTITIONS 3;
insert INTO t1 PARTITION (p1) VALUES (1,2);
 
Version: '11.0.2-MariaDB-debug-log'  
 
mariadbd: /11.0/src/sql/handler.cc:3644: int handler::ha_index_read_map(uchar*, const uchar*, key_part_map, ha_rkey_function): Assertion `table_share->tmp_table != NO_TMP_TABLE || m_lock_type != 2' failed.
230419 18:52:35 [ERROR] mysqld got signal 6 ;
 
??:0(__assert_fail)[0x7f4e95fa9fd6]
sql/handler.cc:3646(handler::ha_index_read_map(unsigned char*, unsigned char const*, unsigned long, ha_rkey_function))[0x56481304da4e]
sql/ha_partition.cc:7741(ha_partition::handle_unordered_scan_next_partition(unsigned char*))[0x5648137d6311]
sql/ha_partition.cc:5961(ha_partition::common_index_read(unsigned char*, bool))[0x5648137c484f]
sql/ha_partition.cc:5830(ha_partition::index_read_map(unsigned char*, unsigned char const*, unsigned long, ha_rkey_function))[0x5648137c3dfe]
sql/handler.cc:3648(handler::ha_index_read_map(unsigned char*, unsigned char const*, unsigned long, ha_rkey_function))[0x56481304de34]
sql/handler.cc:7422(handler::check_duplicate_long_entry_key(unsigned char const*, unsigned int))[0x56481306ee95]
sql/handler.cc:7503(handler::check_duplicate_long_entries(unsigned char const*))[0x5648130705a6]
sql/handler.cc:7780(handler::ha_write_row(unsigned char const*))[0x5648130727c6]
sql/sql_insert.cc:2203(write_record(THD*, TABLE*, st_copy_info*, select_result*))[0x56481266ef49]
sql/sql_insert.cc:1153(mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool, select_result*))[0x564812666153]
sql/sql_parse.cc:4569(mysql_execute_command(THD*, bool))[0x564812733697]
sql/sql_parse.cc:7999(mysql_parse(THD*, char*, unsigned int, Parser_state*))[0x56481274bbbc]
sql/sql_parse.cc:1896(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool))[0x564812721e12]
sql/sql_parse.cc:1407(do_command(THD*, bool))[0x56481271eb4e]
sql/sql_connect.cc:1416(do_handle_one_connection(CONNECT*, bool))[0x564812bebfa7]
sql/sql_connect.cc:1320(handle_one_connection)[0x564812beb904]
perfschema/pfs.cc:2203(pfs_spawn_thread)[0x564813805164]
nptl/pthread_create.c:478(start_thread)[0x7f4e964c4609]
??:0(clone)[0x7f4e96095133]
 
Query (0x6290001092a8): insert INTO t1 PARTITION (p1) VALUES (1,2)

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