[MDEV-31224] Crash with EXPLAIN EXTENDED for multi-table update of system table Created: 2023-05-09  Updated: 2023-06-07  Resolved: 2023-05-12

Status: Closed
Project: MariaDB Server
Component/s: Data Manipulation - Update
Affects Version/s: 10.4, 10.5, 10.6, 10.8, 10.9, 10.10, 10.11, 11.0
Fix Version/s: 11.1.1, 11.0.2, 10.4.30, 10.5.21, 10.6.14, 10.9.7, 10.10.5, 10.11.4

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: regression

Issue Links:
Blocks
Problem/Incident
is caused by MDEV-30539 EXPLAIN EXTENDED: no message with que... Closed

 Description   

Note: Also reproducible on a09f661f439, a fix for MDEV-31181.

CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
 
CREATE TABLE t2 (b INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (3);
 
EXPLAIN EXTENDED UPDATE t1, t2 SET b = 4 WHERE a IN (5,6);
 
## Cleanup
DROP TABLE t1, t2;

10.4 c6ef9b1c

mysqld: /data/src/10.4/sql/field.cc:4324: virtual String* Field_long::val_str(String*, String*): Assertion `marked_for_read()' failed.
230509 16:20:40 [ERROR] mysqld got signal 6 ;
 
#9  0x00007f2c8c853df2 in __GI___assert_fail (assertion=0x558fe26c6400 "marked_for_read()", file=0x558fe26c5780 "/data/src/10.4/sql/field.cc", line=4324, function=0x558fe26c8a60 "virtual String* Field_long::val_str(String*, String*)") at ./assert/assert.c:101
#10 0x0000558fe0a22e14 in Field_long::val_str (this=0x6190000875e8, val_buffer=0x7f2c84c05e40, val_ptr=0x62b000063240) at /data/src/10.4/sql/field.cc:4324
#11 0x0000558fe0b0648f in Item_field::val_str (this=0x62b000063210, str=0x7f2c84c05e40) at /data/src/10.4/sql/item.cc:3246
#12 0x0000558fe0aee5df in Item::print_value (this=0x62b000063210, str=0x7f2c84c065d0) at /data/src/10.4/sql/item.cc:518
#13 0x0000558fe0b29874 in Item_field::print (this=0x62b000063210, str=0x7f2c84c065d0, query_type=QT_EXPLAIN_EXTENDED) at /data/src/10.4/sql/item.cc:7745
#14 0x0000558fe0480b07 in st_select_lex::print_set_clause (this=0x62b00005f970, thd=0x62b00005b208, str=0x7f2c84c065d0, query_type=QT_EXPLAIN_EXTENDED) at /data/src/10.4/sql/sql_select.cc:28112
#15 0x0000558fe04825ef in st_select_lex::print (this=0x62b00005f970, thd=0x62b00005b208, str=0x7f2c84c065d0, query_type=QT_EXPLAIN_EXTENDED) at /data/src/10.4/sql/sql_select.cc:28356
#16 0x0000558fe028f943 in st_select_lex_unit::print (this=0x62b00005f140, str=0x7f2c84c065d0, query_type=QT_EXPLAIN_EXTENDED) at /data/src/10.4/sql/sql_lex.cc:3056
#17 0x0000558fe077e7ae in Explain_query::send_explain (this=0x62b000063fd0, thd=0x62b00005b208, extended=true) at /data/src/10.4/sql/sql_explain.cc:188
#18 0x0000558fe05dd322 in mysql_multi_update (thd=0x62b00005b208, table_list=0x62b000062370, fields=0x62b00005fad0, values=0x62b000060090, conds=0x62b0000636e0, options=4, handle_duplicates=DUP_ERROR, ignore=false, unit=0x62b00005f140, select_lex=0x62b00005f970, result=0x7f2c84c06ec0) at /data/src/10.4/sql/sql_update.cc:1982
#19 0x0000558fe0308c13 in mysql_execute_command (thd=0x62b00005b208) at /data/src/10.4/sql/sql_parse.cc:4520
#20 0x0000558fe03212fb in mysql_parse (thd=0x62b00005b208, rawbuf=0x62b000062228 "EXPLAIN EXTENDED UPDATE t1, t2 SET b = 4 WHERE a IN (5,6)", length=57, parser_state=0x7f2c84c08860, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:7998
#21 0x0000558fe02f77a7 in dispatch_command (command=COM_QUERY, thd=0x62b00005b208, packet=0x62900023f209 "", packet_length=57, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1857
#22 0x0000558fe02f4320 in do_command (thd=0x62b00005b208) at /data/src/10.4/sql/sql_parse.cc:1378
#23 0x0000558fe06f231c in do_handle_one_connection (connect=0x6080000009a8) at /data/src/10.4/sql/sql_connect.cc:1420
#24 0x0000558fe06f1c33 in handle_one_connection (arg=0x6080000009a8) at /data/src/10.4/sql/sql_connect.cc:1324
#25 0x0000558fe135c74c in pfs_spawn_thread (arg=0x615000003508) at /data/src/10.4/storage/perfschema/pfs.cc:1869
#26 0x00007f2c8c8a7fd4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#27 0x00007f2c8c9285bc in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

The failure started happening after this commit in 10.4 (soon to be 10.4.29 / 10.5.20 / 10.6.13 / 10.8.8 / 10.9.6 / 10.10.4 / 10.11.3):

commit f33fc2fae5c3f3e80c4d24348609f3ce5246ca9c
Author: Igor Babaev
Date:   Wed Mar 22 21:59:18 2023 -0700
 
    MDEV-30539 EXPLAIN EXTENDED: no message with queries for DML statements

It is a debug assertion so non-debug build does not crash, but the EXPLAIN output is questionable:

EXPLAIN EXTENDED UPDATE t1, t2 SET b = 4 WHERE a IN (5,6);
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t2	system	NULL	NULL	NULL	NULL	1	100.00	
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
Warnings:
Note	1003	update `test`.`t1` set 3 = 4 where `test`.`t1`.`a` in (5,6)



 Comments   
Comment by Oleksandr Byelkin [ 2023-05-10 ]

OK to push

Comment by Igor Babaev [ 2023-05-12 ]

This bug was pushed into 10.4. It can be merged upstream as it is.

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