[MDEV-20510] Server crashes in my_strcasecmp_utf8 upon adding partition to app-versioned table Created: 2019-09-05  Updated: 2020-05-22  Resolved: 2020-05-22

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

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Aleksey Midenkov
Resolution: Fixed Votes: 0
Labels: regression

Issue Links:
Relates
relates to MDEV-20494 ER_NOT_FORM_FILE or Assertion `!is_se... Closed

 Description   

--source include/have_partition.inc
 
CREATE TABLE t1 (f INT, s DATE, e DATE, PERIOD FOR app(s,e), CONSTRAINT CHECK (f > 0)) PARTITION BY RANGE (f) (PARTITION p1 VALUES LESS THAN (100));
ALTER TABLE t1 ADD PARTITION (PARTITION p2 VALUES LESS THAN (200));
 
# Cleanup
DROP TABLE t1;

10.4 18af13b8

#3  <signal handler called>
#4  0x00005601629e4070 in my_strcasecmp_utf8 (cs=0x560163701380 <my_charset_utf8_general_ci>, s=0x7f8acc1339e0 "CONSTRAINT_1", t=0x0) at /data/src/10.4/strings/ctype-utf8.c:5109
#5  0x0000560161e3b2df in lex_string_cmp (charset=0x560163701380 <my_charset_utf8_general_ci>, a=0x7f8acc139700, b=0x7f8acc014bb0) at /data/src/10.4/sql/lex_string.h:28
#6  0x0000560161e479de in mysql_prepare_create_table (thd=0x7f8acc000b00, create_info=0x7f8add7d0d10, alter_info=0x7f8add7d0c50, db_options=0x7f8add7ce62c, file=0x7f8acc1378c8, key_info_buffer=0x7f8add7ce5f8, key_count=0x7f8add7ce628, create_table_mode=-1) at /data/src/10.4/sql/sql_table.cc:4331
#7  0x0000560161e4046e in mysql_write_frm (lpt=0x7f8add7ce5c0, flags=1) at /data/src/10.4/sql/sql_table.cc:1825
#8  0x00005601622ae6ab in fast_alter_partition_table (thd=0x7f8acc000b00, table=0x7f8acc136a60, alter_info=0x7f8add7d0c50, create_info=0x7f8add7d0d10, table_list=0x7f8acc013250, db=0x7f8add7d0140, table_name=0x7f8add7d0150) at /data/src/10.4/sql/sql_partition.cc:7266
#9  0x0000560161e57817 in mysql_alter_table (thd=0x7f8acc000b00, new_db=0x7f8acc0052b8, new_name=0x7f8acc0056c0, create_info=0x7f8add7d0d10, table_list=0x7f8acc013250, alter_info=0x7f8add7d0c50, order_num=0, order=0x0, ignore=false) at /data/src/10.4/sql/sql_table.cc:9837
#10 0x0000560161ef0485 in Sql_cmd_alter_table::execute (this=0x7f8acc0140d0, thd=0x7f8acc000b00) at /data/src/10.4/sql/sql_alter.cc:508
#11 0x0000560161d6e1a3 in mysql_execute_command (thd=0x7f8acc000b00) at /data/src/10.4/sql/sql_parse.cc:6099
#12 0x0000560161d738ec in mysql_parse (thd=0x7f8acc000b00, rawbuf=0x7f8acc013118 "ALTER TABLE t1 ADD PARTITION (PARTITION p2 VALUES LESS THAN (200))", length=66, parser_state=0x7f8add7d2170, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:7909
#13 0x0000560161d5e8ec in dispatch_command (command=COM_QUERY, thd=0x7f8acc000b00, packet=0x7f8acc008321 "ALTER TABLE t1 ADD PARTITION (PARTITION p2 VALUES LESS THAN (200))", packet_length=66, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1843
#14 0x0000560161d5cf36 in do_command (thd=0x7f8acc000b00) at /data/src/10.4/sql/sql_parse.cc:1360
#15 0x0000560161ee6c47 in do_handle_one_connection (connect=0x560164959b80) at /data/src/10.4/sql/sql_connect.cc:1412
#16 0x0000560161ee6996 in handle_one_connection (arg=0x560164959b80) at /data/src/10.4/sql/sql_connect.cc:1316
#17 0x000056016291cda3 in pfs_spawn_thread (arg=0x5601649bd510) at /data/src/10.4/storage/perfschema/pfs.cc:1862
#18 0x00007f8ae51754a4 in start_thread (arg=0x7f8add7d3700) at pthread_create.c:456
#19 0x00007f8ae36bdd0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97

All of debug, ASAN and non-debug builds crash the same way.

The problem appeared in 10.4 branch with this merge

commit db4a27ab738c3ab43173368117583402f995c4f1
Merge: d1ef02e9592 396da1a7054
Author: Marko Mäkelä
Date:   Sat Aug 31 06:53:45 2019 +0300
 
    Merge 10.3 into 10.4

but since the test case is not applicable to 10.3, I cannot bisect it.



 Comments   
Comment by Elena Stepanova [ 2019-09-17 ]

Same on DROP PARTITION

--source include/have_partition.inc
 
CREATE TABLE t1 (f INT, s DATE, e DATE, PERIOD FOR app(s,e), CONSTRAINT CHECK (f > 0)) PARTITION BY RANGE (f) (PARTITION p1 VALUES LESS THAN (100), PARTITION p2 VALUES LESS THAN (200));
ALTER TABLE t1 DROP PARTITION p2;
 
# Cleanup
DROP TABLE t1;

10.5 stack trace by default has my_strcasecmp_utf8mb3 instead of my_strcasecmp_utf8:

10.5 74551b2b

#3  <signal handler called>
#4  0x0000560023f3dfd2 in my_strcasecmp_utf8mb3 (cs=0x560024c52020 <my_charset_utf8mb3_general_ci>, s=0x7efc6012d618 "CONSTRAINT_1", t=0x0) at /data/src/10.5/strings/ctype-utf8.c:5111
#5  0x000056002335a236 in lex_string_cmp (charset=0x560024c52020 <my_charset_utf8mb3_general_ci>, a=0x7efc601516d0, b=0x7efc600142e0) at /data/src/10.5/sql/lex_string.h:66
#6  0x0000560023366b19 in mysql_prepare_create_table (thd=0x7efc60000b10, create_info=0x7efc70bdb4e0, alter_info=0x7efc70bdb420, db_options=0x7efc70bd8dcc, file=0x7efc60131428, key_info_buffer=0x7efc70bd8d98, key_count=0x7efc70bd8dc8, create_table_mode=-1) at /data/src/10.5/sql/sql_table.cc:4346
#7  0x000056002335f456 in mysql_write_frm (lpt=0x7efc70bd8d60, flags=1) at /data/src/10.5/sql/sql_table.cc:1825
#8  0x00005600237b0780 in fast_alter_partition_table (thd=0x7efc60000b10, table=0x7efc60130150, alter_info=0x7efc70bdb420, create_info=0x7efc70bdb4e0, table_list=0x7efc60013498, db=0x7efc70bda900, table_name=0x7efc70bda910) at /data/src/10.5/sql/sql_partition.cc:7255
#9  0x0000560023376992 in mysql_alter_table (thd=0x7efc60000b10, new_db=0x7efc600052c8, new_name=0x7efc600056d0, create_info=0x7efc70bdb4e0, table_list=0x7efc60013498, alter_info=0x7efc70bdb420, order_num=0, order=0x0, ignore=false) at /data/src/10.5/sql/sql_table.cc:9846
#10 0x00005600234195db in Sql_cmd_alter_table::execute (this=0x7efc60013b68, thd=0x7efc60000b10) at /data/src/10.5/sql/sql_alter.cc:522
#11 0x000056002327f0dd in mysql_execute_command (thd=0x7efc60000b10) at /data/src/10.5/sql/sql_parse.cc:5896
#12 0x0000560023285348 in mysql_parse (thd=0x7efc60000b10, rawbuf=0x7efc600133a8 "ALTER TABLE t1 DROP PARTITION p2", length=32, parser_state=0x7efc70bdc580, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:7935
#13 0x000056002327068b in dispatch_command (command=COM_QUERY, thd=0x7efc60000b10, packet=0x7efc60008341 "ALTER TABLE t1 DROP PARTITION p2", packet_length=32, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:1847
#14 0x000056002326eda2 in do_command (thd=0x7efc60000b10) at /data/src/10.5/sql/sql_parse.cc:1364
#15 0x000056002340f3f3 in do_handle_one_connection (connect=0x56002756af20, put_in_cache=true) at /data/src/10.5/sql/sql_connect.cc:1422
#16 0x000056002340f122 in handle_one_connection (arg=0x5600274a4df0) at /data/src/10.5/sql/sql_connect.cc:1319
#17 0x00005600239667af in pfs_spawn_thread (arg=0x5600274a4a50) at /data/src/10.5/storage/perfschema/pfs.cc:1862
#18 0x00007efc7857e4a4 in start_thread (arg=0x7efc70bdd700) at pthread_create.c:456
#19 0x00007efc76ac6d0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97

Comment by Elena Stepanova [ 2020-05-16 ]

Doesn't fail on the current 10.4 a4996f95 or 10.5 69077dea

Comment by Elena Stepanova [ 2020-05-22 ]

The failure stopped happening on 10.4 after this commit:

commit 76063c2a13ff0a9aebf071d24a740f96882c4339
Author: Aleksey Midenkov
Date:   Fri Apr 3 23:55:48 2020 +0300
 
    MDEV-20494 ER_NOT_FORM_FILE or assertion upon adding partition to period table
    
    - Fixed mysql_prepare_create_table() constraint duplicate checking;
    - Refactored period constraint handling in mysql_prepare_alter_table():
      * No need to allocate new objects;
      * Keep old constraint name but exclude it from dup checking by automatic_name;
    - Some minor memory leaks fixed;
    - Some conceptual TODOs.

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