[MDEV-30442] Assertion `!m_innodb' failed in ha_partition::cmp_ref on MULTI-DELETE Created: 2023-01-21  Updated: 2023-03-20  Resolved: 2023-03-17

Status: Closed
Project: MariaDB Server
Component/s: Data Manipulation - Delete, Storage Engine - InnoDB
Affects Version/s: 11.0
Fix Version/s: 11.0.2

Type: Bug Priority: Critical
Reporter: Roel Van de Paar Assignee: Sergei Petrunia
Resolution: Fixed Votes: 0
Labels: regression, stack-smashing

Issue Links:
Duplicate
is duplicated by MDEV-30672 Assertion `!m_innodb' failed in ha_p... Closed
Relates
relates to MDEV-18794 Assertion `!m_innodb' failed in ha_pa... Closed

 Description   

CREATE TABLE t1 (c INT) ENGINE=InnoDB;
CREATE TABLE t2 (c INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (1);
DROP TABLE t1;
CREATE TABLE t1 (a CHAR(5)) ENGINE=InnoDB PARTITION BY RANGE COLUMNS (a) (PARTITION p0 VALUES LESS THAN ('m'),PARTITION p VALUES LESS THAN ('z'));
INSERT INTO t1 VALUES ('a'),('s');
DELETE t1 FROM t1,t2;

11.0.1 bb-11.0-midenok-MDEV-25292 b986107a777e3f900f235d969d569358c7a5edfe (Debug)

mysqld: /test/bb-11.0-midenok-MDEV-25292_dbg/sql/ha_partition.cc:10761: virtual int ha_partition::cmp_ref(const uchar*, const uchar*): Assertion `!m_innodb' failed.

11.0.1 bb-11.0-midenok-MDEV-25292 b986107a777e3f900f235d969d569358c7a5edfe (Debug)

Core was generated by `/test/bb-11.0-midenok-MDEV-25292_MD200123-mariadb-11.0.1-linux-x86_64-dbg/bin/m'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=22378509116992)
    at ./nptl/pthread_kill.c:44
[Current thread is 1 (Thread 0x145a67162640 (LWP 283423))]
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=22378509116992) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=22378509116992) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=22378509116992, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x0000145ab0674476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x0000145ab065a7f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x0000145ab065a71b in __assert_fail_base (fmt=0x145ab080f150 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5596c84b652a "!m_innodb", file=0x5596c84b68f0 "/test/bb-11.0-midenok-MDEV-25292_dbg/sql/ha_partition.cc", line=10761, function=<optimized out>) at ./assert/assert.c:92
#6  0x0000145ab066be96 in __GI___assert_fail (assertion=0x5596c84b652a "!m_innodb", file=0x5596c84b68f0 "/test/bb-11.0-midenok-MDEV-25292_dbg/sql/ha_partition.cc", line=10761, function=0x5596c84b6a28 "virtual int ha_partition::cmp_ref(const uchar*, const uchar*)") at ./assert/assert.c:101
#7  0x00005596c7d02beb in ha_partition::cmp_ref (this=0x145a38082c90, ref1=<optimized out>, ref2=<optimized out>) at /test/bb-11.0-midenok-MDEV-25292_dbg/sql/ha_partition.cc:10761
#8  0x00005596c7766c89 in refpos_order_cmp (arg=<optimized out>, a=<optimized out>, b=<optimized out>) at /test/bb-11.0-midenok-MDEV-25292_dbg/sql/sql_delete.cc:1111
#9  0x00005596c810f4d0 in tree_insert (tree=0x145a380169d8, key=0x145a38085218, key_size=0, custom_arg=0x145a38082c90) at /test/bb-11.0-midenok-MDEV-25292_dbg/mysys/tree.c:249
#10 0x00005596c776802e in Unique::unique_add (ptr=0x145a38085218, this=0x145a38016820) at /test/bb-11.0-midenok-MDEV-25292_dbg/sql/uniques.h:66
#11 multi_delete::send_data (this=0x145a380149f0, values=<optimized out>) at /test/bb-11.0-midenok-MDEV-25292_dbg/sql/sql_delete.cc:1405
#12 0x00005596c7829aec in select_result_sink::send_data_with_check (sent=<optimized out>, u=<optimized out>, items=@0x145a38005a70: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x145a38014980, last = 0x145a38014980, elements = 1}, <No data fields>}, this=<optimized out>) at /test/bb-11.0-midenok-MDEV-25292_dbg/sql/sql_class.h:5735
#13 end_send (join=0x145a38014a58, join_tab=0x145a3808b0e0, end_of_records=<optimized out>) at /test/bb-11.0-midenok-MDEV-25292_dbg/sql/sql_select.cc:23122
#14 0x00005596c77fc9a2 in evaluate_join_record (join=join@entry=0x145a38014a58, join_tab=join_tab@entry=0x145a3808ad28, error=error@entry=0) at /test/bb-11.0-midenok-MDEV-25292_dbg/sql/sql_select.cc:22116
#15 0x00005596c78111ac in sub_select (join=0x145a38014a58, join_tab=0x145a3808ad28, end_of_records=false) at /test/bb-11.0-midenok-MDEV-25292_dbg/sql/sql_select.cc:21925
#16 0x00005596c77fc9a2 in evaluate_join_record (join=join@entry=0x145a38014a58, join_tab=join_tab@entry=0x145a3808a970, error=error@entry=0) at /test/bb-11.0-midenok-MDEV-25292_dbg/sql/sql_select.cc:22116
#17 0x00005596c78110a2 in sub_select (join=0x145a38014a58, join_tab=0x145a3808a970, end_of_records=false) at /test/bb-11.0-midenok-MDEV-25292_dbg/sql/sql_select.cc:21886
#18 0x00005596c78448c7 in do_select (procedure=<optimized out>, join=0x145a38014a58) at /test/bb-11.0-midenok-MDEV-25292_dbg/sql/sql_select.cc:21429
#19 JOIN::exec_inner (this=this@entry=0x145a38014a58) at /test/bb-11.0-midenok-MDEV-25292_dbg/sql/sql_select.cc:4823
#20 0x00005596c7844e2c in JOIN::exec (this=this@entry=0x145a38014a58) at /test/bb-11.0-midenok-MDEV-25292_dbg/sql/sql_select.cc:4601
#21 0x00005596c7842d95 in mysql_select (thd=thd@entry=0x145a38000d58, tables=0x145a38013a78, fields=@0x145a38005a70: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x145a38014980, last = 0x145a38014980, elements = 1}, <No data fields>}, conds=conds@entry=0x0, og_num=og_num@entry=0, order=order@entry=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=37385559870336, result=0x145a380149f0, unit=0x145a38004fa0, select_lex=0x145a380057d0) at /test/bb-11.0-midenok-MDEV-25292_dbg/sql/sql_select.cc:5081
#22 0x00005596c77bc06d in mysql_execute_command (thd=thd@entry=0x145a38000d58, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/bb-11.0-midenok-MDEV-25292_dbg/sql/sql_parse.cc:4869
#23 0x00005596c77c0aac in mysql_parse (thd=thd@entry=0x145a38000d58, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x145a671612c0) at /test/bb-11.0-midenok-MDEV-25292_dbg/sql/sql_parse.cc:8005
#24 0x00005596c77c2c40 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x145a38000d58, packet=packet@entry=0x145a3800af29 "DELETE t1 FROM t1,t2", packet_length=packet_length@entry=20, blocking=blocking@entry=true) at /test/bb-11.0-midenok-MDEV-25292_dbg/sql/sql_class.h:243
#25 0x00005596c77c4aa0 in do_command (thd=0x145a38000d58, blocking=blocking@entry=true) at /test/bb-11.0-midenok-MDEV-25292_dbg/sql/sql_parse.cc:1407
#26 0x00005596c7911dc6 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5596ca8191d8, put_in_cache=put_in_cache@entry=true) at /test/bb-11.0-midenok-MDEV-25292_dbg/sql/sql_connect.cc:1416
#27 0x00005596c7912025 in handle_one_connection (arg=0x5596ca8191d8) at /test/bb-11.0-midenok-MDEV-25292_dbg/sql/sql_connect.cc:1318
#28 0x0000145ab06c6b43 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#29 0x0000145ab0758a00 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

No unexpected issues observed on optimized builds.



 Comments   
Comment by Roel Van de Paar [ 2023-01-21 ]

Additional testcase

CREATE TABLE t1 (c1 INT, c2 INT) ENGINE=InnoDB PARTITION BY HASH (c1) PARTITIONS 4;
CREATE TABLE t2 (c1 INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,2),(2,1);
INSERT INTO t2 VALUES (1);
DELETE t1 FROM t1,t2;

Comment by Roel Van de Paar [ 2023-01-21 ]

MTR will crash with this testcase:

--source include/have_innodb.inc
--source include/have_partition.inc
 
CREATE TABLE t1 (c1 INT, c2 INT) ENGINE=InnoDB PARTITION BY HASH (c1) PARTITIONS 4;
CREATE TABLE t2 (c1 INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,2),(2,1);
INSERT INTO t2 VALUES (1);
DELETE t1 FROM t1,t2;

However, in MTR's case we observe stack smashing:

11.0.1 bb-11.0-midenok-MDEV-25292 b986107a777e3f900f235d969d569358c7a5edfe (Debug)

2023-01-21 12:10:08 0 [Note] /test/bb-11.0-midenok-MDEV-25292_MD200123-mariadb-11.0.1-linux-x86_64-dbg/bin/mariadbd: ready for connections.
Version: '11.0.1-MariaDB-debug-log'  socket: '/tmp/HKQRzOvfID/mysqld.1.sock'  port: 16000  MariaDB Server
mariadbd: /test/bb-11.0-midenok-MDEV-25292_dbg/sql/ha_partition.cc:10761: virtual int ha_partition::cmp_ref(const uchar*, const uchar*): Assertion `!m_innodb' failed.
----------SERVER LOG END-------------
 
 - found 'core.2431025' (0/5)
Guessing that core was generated by '/test/bb-11.0-midenok-MDEV-25292_MD200123-mariadb-11.0.1-linux-x86_64-dbg/bin/mysqlhotcopy'
Output from gdb follows. The first stack trace is from the failing thread.
The following stack traces are from all threads (so the failing one is
duplicated).
--------------------------
"/test/bb-11.0-midenok-MDEV-25292_MD200123-mariadb-11.0.1-linux-x86_64-dbg/bin/mysqlhotcopy": not in executable format: file format not recognized
[New LWP 2431130]
[New LWP 2431025]
[New LWP 2431115]
[New LWP 2431119]
[New LWP 2431122]
[New LWP 2431118]
[New LWP 2431031]
[New LWP 2431121]
[New LWP 2431027]
[New LWP 2431114]
[New LWP 2431117]
[New LWP 2431120]
[New LWP 2431123]
[New LWP 2431126]
[New LWP 2431127]
Core was generated by `/test/bb-11.0-midenok-MDEV-25292_MD200123-mariadb-11.0.1-linux-x86_64-dbg/bin/m'.
Program terminated with signal SIGABRT, Aborted.
#0  0x000014744a32ba7c in ?? ()
[Current thread is 1 (LWP 2431130)]
 
Thread 15 (LWP 2431127):
#0  0x000014744a2d821a in ?? ()
#1  0x000014743aa74b10 in ?? ()
#2  0x0000000000000000 in ?? ()
 
Thread 14 (LWP 2431126):
#0  0x000014744a326197 in ?? ()
#1  0x00001474100093b8 in ?? ()
#2  0x000001894a33a4d3 in ?? ()
#3  0x0000555d4675090c in ?? ()
#4  0x0000000000000000 in ?? ()
 
Thread 13 (LWP 2431123):
#0  0x000014744a326197 in ?? ()
#1  0x000014743ac75a50 in ?? ()
#2  0x00000189fffffd98 in ?? ()
#3  0x0000555d46f83848 in ?? ()
#4  0x000014743ac75bc0 in ?? ()
#5  0x0000000000000000 in ?? ()
 
Thread 12 (LWP 2431120):
#0  0x000014744a326197 in ?? ()
#1  0x000014743b278ae0 in ?? ()
#2  0x0000008920000cf0 in ?? ()
#3  0x0000555d47ececcc in ?? ()
#4  0x000014743b278b50 in ?? ()
#5  0x000014743b278b50 in ?? ()
#6  0x0000555d47ece808 in ?? ()
#7  0x0000000000000001 in ?? ()
#8  0x000014744a32935d in ?? ()
#9  0x0000555d47ececa0 in ?? ()
#10 0x0000555d47ece808 in ?? ()
#11 0x000000000000000b in ?? ()
#12 0x0000000100000000 in ?? ()
#13 0x0000555d47ececb4 in ?? ()
#14 0x0000000000000017 in ?? ()
#15 0x000014743b278ad0 in ?? ()
#16 0x0000000000000000 in ?? ()
 
Thread 11 (LWP 2431117):
#0  0x000014744a326197 in ?? ()
#1  0x0000147448361ae0 in ?? ()
#2  0x0000008930000d40 in ?? ()
#3  0x0000555d47eceb48 in ?? ()
#4  0x0000147448361b50 in ?? ()
#5  0x0000147448361b50 in ?? ()
#6  0x0000555d47ece808 in ?? ()
#7  0x0000000000000001 in ?? ()
#8  0x000014744a32935d in ?? ()
#9  0x0000555d47eceb20 in ?? ()
#10 0x0000555d47ece808 in ?? ()
#11 0x0000000000000002 in ?? ()
#12 0x0000000000000000 in ?? ()
 
Thread 10 (LWP 2431114):
#0  0x000014744a326197 in ?? ()
#1  0x0000147448763a50 in ?? ()
#2  0x0000008945be11b2 in ?? ()
#3  0x0000555d47ecea48 in ?? ()
#4  0x0000147448763b50 in ?? ()
#5  0x0000147448763b50 in ?? ()
#6  0x0000555d47ece808 in ?? ()
#7  0x0000000000000001 in ?? ()
#8  0x000014744a32935d in ?? ()
#9  0x0000555d47ecea20 in ?? ()
#10 0x0000555d47ece808 in ?? ()
#11 0x0000000000000002 in ?? ()
#12 0x0000000000000000 in ?? ()
 
Thread 9 (LWP 2431027):
#0  0x000014744a326197 in ?? ()
#1  0x0000000000000000 in ?? ()
 
Thread 8 (LWP 2431121):
#0  0x000014744a326197 in ?? ()
#1  0x0000000000000000 in ?? ()
 
Thread 7 (LWP 2431031):
#0  0x000014744a326197 in ?? ()
#1  0x0000147448d6ea20 in ?? ()
#2  0x00000189fffffd98 in ?? ()
#3  0x0000555d46674270 in ?? ()
#4  0x0000147448d6ebe0 in ?? ()
#5  0x0000000000000000 in ?? ()
 
Thread 6 (LWP 2431118):
#0  0x000014744a326197 in ?? ()
#1  0x0000000000000000 in ?? ()
 
Thread 5 (LWP 2431122):
#0  0x000014744a326197 in ?? ()
#1  0x0000000000000000 in ?? ()
 
Thread 4 (LWP 2431119):
#0  0x000014744a326197 in ?? ()
#1  0x0000000000000000 in ?? ()
 
Thread 3 (LWP 2431115):
#0  0x000014744a326197 in ?? ()
#1  0x0000147448562ae0 in ?? ()
#2  0x0000008934000d40 in ?? ()
#3  0x0000555d47eceac8 in ?? ()
#4  0x0000147448562b50 in ?? ()
#5  0x0000147448562b50 in ?? ()
#6  0x0000555d47ece808 in ?? ()
#7  0x0000000000000001 in ?? ()
#8  0x000014744a32935d in ?? ()
#9  0x0000555d47eceaa0 in ?? ()
#10 0x0000555d47ece808 in ?? ()
#11 0x0000000000000004 in ?? ()
#12 0x0000000000000000 in ?? ()
 
Thread 2 (LWP 2431025):
#0  0x000014744a3add7f in ?? ()
#1  0xffffff00ffffffff in ?? ()
#2  0x0000555d48261308 in ?? ()
#3  0x0000000000000002 in ?? ()
#4  0xffffffffffffffff in ?? ()
#5  0x00007fff68099c20 in ?? ()
#6  0x0000555d4515ccfa in ?? ()
#7  0x0000000000000000 in ?? ()
 
Thread 1 (LWP 2431130):
#0  0x000014744a32ba7c in ?? ()
#1  0x0000147408187cfc in ?? ()
#2  0x0000147408187bd0 in ?? ()
#3  0x0000147408187cfc in ?? ()
#4  0x0000000000000000 in ?? ()
 
 - saving '/test/bb-11.0-midenok-MDEV-25292_MD200123-mariadb-11.0.1-linux-x86_64-dbg/mysql-test/var/log/main.test-innodb/' to '/test/bb-11.0-midenok-MDEV-25292_MD200123-mariadb-11.0.1-linux-x86_64-dbg/mysql-test/var/log/main.test-innodb/'
--------------------------------------------------------------------------

Comment by Aleksey Midenkov [ 2023-01-24 ]

Reproducible in trunk.

Comment by Roel Van de Paar [ 2023-02-24 ]

Confirmed. psergei MDEV-30672 looks related.

Comment by Roel Van de Paar [ 2023-02-24 ]

Additional testcase

CREATE TABLE t (c1 INT,c2 INT) ENGINE=InnoDB PARTITION BY RANGE (c1) SUBPARTITION BY KEY(c2) (PARTITION s0 VALUES LESS THAN (100) (SUBPARTITION s1 TABLESPACE=s,SUBPARTITION s2 TABLESPACE=s),PARTITION s3 VALUES LESS THAN (1000) (SUBPARTITION s4,SUBPARTITION s5 TABLESPACE=s),PARTITION s6 VALUES LESS THAN (10000) (SUBPARTITION s7,SUBPARTITION s8));
INSERT INTO t VALUES (0,0),(1,1);
DELETE FROM t2,t3 USING t AS t1 JOIN t AS t2 JOIN t AS t3;

Comment by Sergei Petrunia [ 2023-02-24 ]

bb-11.0-mdev30442

Comment by Sergei Petrunia [ 2023-02-24 ]

oleg.smirnov, please review.

Comment by Sergei Petrunia [ 2023-02-24 ]

TODO: close MDEV-30672 when we've closed this one.

Comment by Oleg Smirnov [ 2023-03-13 ]

The patch looks good, no objections from me.

Generated at Thu Feb 08 10:16:17 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.