[MDEV-25555] Server crashes in tree_record_pos after INPLACE-recreating index on HEAP table Created: 2021-04-28  Updated: 2021-11-08  Resolved: 2021-11-03

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table, Storage Engine - Memory
Affects Version/s: 10.5, 10.6
Fix Version/s: 10.5.14, 10.6.6

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Aleksey Midenkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-7318 RENAME INDEX Closed
Relates
relates to MDEV-25803 Inplace ALTER breaks MyISAM/Aria tabl... Closed

 Description   

CREATE TABLE t1 (a int, KEY idx1(a), KEY idx2 USING BTREE(a)) ENGINE=MEMORY;
ALTER TABLE t1 DROP KEY idx1, ADD KEY idx3(a);
DELETE FROM t1 WHERE a = 10;
 
# Cleanup
DROP TABLE t1;

10.5 559efad4

#3  <signal handler called>
#4  0x000055b715d5a979 in tree_record_pos (tree=0x7fdbec0f9090, key=0x7fdbec215d16, flag=HA_READ_KEY_EXACT, custom_arg=0x7fdbfd249020) at /data/src/10.5/mysys/tree.c:535
#5  0x000055b7158569f4 in hp_rb_records_in_range (info=0x7fdbec215a28, inx=0, min_key=0x7fdbfd2491f0, max_key=0x7fdbfd249210) at /data/src/10.5/storage/heap/hp_hash.c:76
#6  0x000055b715854b2b in ha_heap::records_in_range (this=0x7fdbec203210, inx=0, min_key=0x7fdbfd2491f0, max_key=0x7fdbfd249210, pages=0x7fdbfd2491c0) at /data/src/10.5/storage/heap/ha_heap.cc:584
#7  0x000055b715284690 in handler::multi_range_read_info_const (this=0x7fdbec203210, keyno=0, seq=0x7fdbfd2492e0, seq_init_param=0x7fdbfd249310, n_ranges_arg=0, bufsz=0x7fdbfd249898, flags=0x7fdbfd249894, cost=0x7fdbfd249980) at /data/src/10.5/sql/multi_range_read.cc:177
#8  0x000055b7155a27bd in check_quick_select (param=0x7fdbfd249c10, idx=0, index_only=false, tree=0x7fdbec233a88, update_tbl_stats=true, mrr_flags=0x7fdbfd249894, bufsize=0x7fdbfd249898, cost=0x7fdbfd249980, is_ror_scan=0x7fdbfd249892) at /data/src/10.5/sql/opt_range.cc:11558
#9  0x000055b71559802a in get_key_scans_params (param=0x7fdbfd249c10, tree=0x7fdbec2339f8, index_read_must_be_used=false, for_range_access=true, read_time=12.5) at /data/src/10.5/sql/opt_range.cc:7462
#10 0x000055b71558c962 in SQL_SELECT::test_quick_select (this=0x7fdbec0160b8, thd=0x7fdbec000db8, keys_to_use=..., prev_tables=0, limit=18446744073709551615, force_quick_range=false, ordered_output=false, remove_false_parts_of_where=false, only_single_index_range_scan=false) at /data/src/10.5/sql/opt_range.cc:2931
#11 0x000055b7151b14fc in SQL_SELECT::check_quick (this=0x7fdbec0160b8, thd=0x7fdbec000db8, force_quick_range=false, limit=18446744073709551615) at /data/src/10.5/sql/opt_range.h:1718
#12 0x000055b7155da603 in mysql_delete (thd=0x7fdbec000db8, table_list=0x7fdbec0153d0, conds=0x7fdbec015c90, order_list=0x7fdbec005a08, limit=18446744073709551615, options=0, result=0x0) at /data/src/10.5/sql/sql_delete.cc:511
#13 0x000055b715080cd7 in mysql_execute_command (thd=0x7fdbec000db8) at /data/src/10.5/sql/sql_parse.cc:4870
#14 0x000055b71508b790 in mysql_parse (thd=0x7fdbec000db8, rawbuf=0x7fdbec0152f0 "DELETE FROM t1 WHERE a = 10", length=27, parser_state=0x7fdbfd24b490, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:8099
#15 0x000055b71507770b in dispatch_command (command=COM_QUERY, thd=0x7fdbec000db8, packet=0x7fdbec00b5a9 "DELETE FROM t1 WHERE a = 10", packet_length=27, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:1891
#16 0x000055b715075efd in do_command (thd=0x7fdbec000db8) at /data/src/10.5/sql/sql_parse.cc:1370
#17 0x000055b71522573b in do_handle_one_connection (connect=0x55b718098fa8, put_in_cache=true) at /data/src/10.5/sql/sql_connect.cc:1410
#18 0x000055b71522549e in handle_one_connection (arg=0x55b717f9fc18) at /data/src/10.5/sql/sql_connect.cc:1312
#19 0x000055b7157898ed in pfs_spawn_thread (arg=0x55b718098978) at /data/src/10.5/storage/perfschema/pfs.cc:2201
#20 0x00007fdc02ef5609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#21 0x00007fdc02ac9293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Reproducible on 10.5-10.6, debug- and release alike.
Not reproducible on 10.4 and previous versions, apparently because it doesn't do it inplace, and doesn't accept explicit ALGORITHM=INPLACE for this operation.
Not reproducible with MyISAM (at least with otherwise the same test case).
Not reproducible with ALTER .. ALGORITHM=COPY.

The failure appeared in 10.5 after this commit:

commit 193725b81ed813d0318c1fa82de284c337246d9e
Author: Aleksey Midenkov
Date:   Tue Mar 3 13:50:33 2020 +0300
 
    MDEV-7318 RENAME INDEX

(but not reproducible with RENAME INDEX instead of DROP / ADD).



 Comments   
Comment by Aleksey Midenkov [ 2021-10-13 ]

Please review bb-10.5-midenok

Comment by Oleksandr Byelkin [ 2021-10-26 ]

IMHO "or replace" is not needed, fix and push

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