[MDEV-22424] Server crashes in handler::check_duplicate_long_entry_key or Assertion `inited == NONE || lookup_handler != this' failed upon DELETE FOR PORTION on table with long unique key Created: 2020-04-30  Updated: 2020-05-05  Resolved: 2020-05-05

Status: Closed
Project: MariaDB Server
Component/s: Server, Versioned Tables
Affects Version/s: 10.5
Fix Version/s: 10.5.3

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: regression

Issue Links:
Relates
relates to MDEV-22185 Failing assertion: node->pcur->rel_po... Closed

 Description   

--source include/have_innodb.inc
 
CREATE TABLE t1 (
    a varchar(8192),
    s date,
    e date,
    PERIOD FOR p(s,e),
    UNIQUE KEY (a)
) ENGINE=InnoDB;
 
INSERT INTO t1 VALUES ('foo','2020-10-24','2024-04-01');
FLUSH TABLES;
DELETE FROM t1 FOR PORTION OF p FROM '2021-08-01' TO '2023-12-01';
 
# Cleanup
DROP TABLE t1;

10.5 RelWithDebInfo 5193c1b5

#3  <signal handler called>
#4  __memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:242
#5  0x0000560c2e366a61 in memcpy (__len=<optimized out>, __src=<optimized out>, __dest=<optimized out>) at /usr/include/x86_64-linux-gnu/bits/string3.h:53
#6  handler::check_duplicate_long_entry_key (this=this@entry=0x7fea4c14a4e0, new_rec=new_rec@entry=0x7fea4c0f8720 "\374\003", key_no=key_no@entry=0) at /data/src/10.5/sql/handler.cc:6613
#7  0x0000560c2e366d12 in handler::check_duplicate_long_entries (this=this@entry=0x7fea4c14a4e0, new_rec=new_rec@entry=0x7fea4c0f8720 "\374\003") at /data/src/10.5/sql/handler.cc:6694
#8  0x0000560c2e367515 in handler::ha_write_row (this=0x7fea4c14a4e0, buf=0x7fea4c0f8720 "\374\003") at /data/src/10.5/sql/handler.cc:6964
#9  0x0000560c2e234efd in TABLE::period_make_insert (this=this@entry=0x7fea4c17d828, src=<optimized out>, dst=0x7fea4c153488) at /data/src/10.5/sql/table.cc:8624
#10 0x0000560c2e48f771 in update_portion_of_time (inside_period=<synthetic pointer>, period_conds=..., table=0x7fea4c17d828, thd=0x7fea4c0009b8) at /data/src/10.5/sql/sql_delete.cc:268
#11 mysql_delete (thd=thd@entry=0x7fea4c0009b8, table_list=0x7fea4c010430, conds=<optimized out>, order_list=order_list@entry=0x7fea4c0052a8, limit=18446744073709551615, options=<optimized out>, result=0x0) at /data/src/10.5/sql/sql_delete.cc:788
#12 0x0000560c2e17d6ba in mysql_execute_command (thd=thd@entry=0x7fea4c0009b8) at /data/src/10.5/sql/sql_parse.cc:4749
#13 0x0000560c2e182c3b in mysql_parse (thd=thd@entry=0x7fea4c0009b8, rawbuf=<optimized out>, length=65, parser_state=parser_state@entry=0x7fea7e766550, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /data/src/10.5/sql/sql_parse.cc:7957
#14 0x0000560c2e17880d in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7fea4c0009b8, packet=packet@entry=0x7fea4c007c69 "DELETE FROM t1 FOR PORTION OF p FROM '2021-08-01' TO '2023-12-01'", packet_length=packet_length@entry=65, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /data/src/10.5/sql/sql_parse.cc:1840
#15 0x0000560c2e176c61 in do_command (thd=0x7fea4c0009b8) at /data/src/10.5/sql/sql_parse.cc:1359
#16 0x0000560c2e25e7a4 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x560c304f5088, put_in_cache=put_in_cache@entry=true) at /data/src/10.5/sql/sql_connect.cc:1422
#17 0x0000560c2e25eaa3 in handle_one_connection (arg=arg@entry=0x560c304f5088) at /data/src/10.5/sql/sql_connect.cc:1319
#18 0x0000560c2e578ce4 in pfs_spawn_thread (arg=0x560c304b4708) at /data/src/10.5/storage/perfschema/pfs.cc:2201
#19 0x00007fea8b1ae4a4 in start_thread (arg=0x7fea7e767700) at pthread_create.c:456
#20 0x00007fea892e2d0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97

10.5 debug 5193c1b5

mariadbd: /data/src/10.5/sql/handler.cc:6963: int handler::ha_write_row(const uchar*): Assertion `inited == NONE || lookup_handler != this' failed.
200430 15:31:34 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f50b41aff12 in __GI___assert_fail (assertion=0x558250581078 "inited == NONE || lookup_handler != this", file=0x55825057e9be "/data/src/10.5/sql/handler.cc", line=6963, function=0x558250583620 <handler::ha_write_row(unsigned char const*)::__PRETTY_FUNCTION__> "int handler::ha_write_row(const uchar*)") at assert.c:101
#8  0x000055824f965866 in handler::ha_write_row (this=0x7f5080118af0, buf=0x7f5080211900 "\374\003") at /data/src/10.5/sql/handler.cc:6963
#9  0x000055824f74b1b6 in TABLE::period_make_insert (this=0x7f50801ef1e8, src=0x7f5080014230, dst=0x7f5080132c08) at /data/src/10.5/sql/table.cc:8624
#10 0x000055824fb2b4f2 in update_portion_of_time (thd=0x7f5080000b18, table=0x7f50801ef1e8, period_conds=..., inside_period=0x7f50a96ff500) at /data/src/10.5/sql/sql_delete.cc:268
#11 0x000055824fb2d473 in mysql_delete (thd=0x7f5080000b18, table_list=0x7f5080013a80, conds=0x7f5080014fb0, order_list=0x7f50800055c8, limit=18446744073709551615, options=0, result=0x0) at /data/src/10.5/sql/sql_delete.cc:788
#12 0x000055824f601733 in mysql_execute_command (thd=0x7f5080000b18) at /data/src/10.5/sql/sql_parse.cc:4749
#13 0x000055824f60c182 in mysql_parse (thd=0x7f5080000b18, rawbuf=0x7f5080013950 "DELETE FROM t1 FOR PORTION OF p FROM '2021-08-01' TO '2023-12-01'", length=65, parser_state=0x7f50a9700520, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:7957
#14 0x000055824f5f848a in dispatch_command (command=COM_QUERY, thd=0x7f5080000b18, packet=0x7f50800086a9 "DELETE FROM t1 FOR PORTION OF p FROM '2021-08-01' TO '2023-12-01'", packet_length=65, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:1840
#15 0x000055824f5f6c1c in do_command (thd=0x7f5080000b18) at /data/src/10.5/sql/sql_parse.cc:1359
#16 0x000055824f79a224 in do_handle_one_connection (connect=0x558253174398, put_in_cache=true) at /data/src/10.5/sql/sql_connect.cc:1422
#17 0x000055824f799f53 in handle_one_connection (arg=0x558253174398) at /data/src/10.5/sql/sql_connect.cc:1319
#18 0x000055824fccf774 in pfs_spawn_thread (arg=0x5582530851f8) at /data/src/10.5/storage/perfschema/pfs.cc:2201
#19 0x00007f50b61384a4 in start_thread (arg=0x7f50a9701700) at pthread_create.c:456
#20 0x00007f50b426cd0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97

Not reproducible with MyISAM.
Not reproducible on 10.4.
The problem appeared in 10.5 branch after this commit:

commit 0515577d128318e1b62511846d88d0c56226168d
Author: Sergei Golubchik
Date:   Thu Mar 5 19:19:57 2020 +0100
 
    cleanup: prepare "update_handler" for WITHOUT OVERLAPS
    
    * rename to a generic name
    * move remaning initializations from query exec to prepare time
    * simplify/unify key handling in open_table_from_share and delayed
    * remove dead code
    * move tests where they belong



 Comments   
Comment by Sergei Golubchik [ 2020-05-04 ]

Doesn't crash after the second fix for MDEV-22185.

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