[MDEV-8321] Assertion `! is_set()' failed in Diagnostics_area::set_eof_status on EXPLAIN INSERT ... UNION Created: 2015-06-16  Updated: 2015-10-06  Resolved: 2015-10-06

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.0, 10.1
Fix Version/s: 10.0.22

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Oleksandr Byelkin
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-6223 Assertion `! is_set()' fails in Diagn... Closed

 Description   

Note: See also MDEV-6223.

Stack trace from 10.0 commit 909f7607018e644754a2c41b791b44b25a05e8fb

10.0/sql/sql_error.cc:407: void Diagnostics_area::set_eof_status(THD*): Assertion `! is_set()' failed.
150616 14:48:17 [ERROR] mysqld got signal 6 ;
 
#6  0x00007fa8a01c6311 in *__GI___assert_fail (assertion=0xf06ca7 "! is_set()", file=<optimized out>, line=407, function=0xf07a60 "void Diagnostics_area::set_eof_status(THD*)") at assert.c:81
#7  0x0000000000659342 in Diagnostics_area::set_eof_status (this=0x7fa89b7d8d28, thd=0x7fa89b7d4070) at 10.0/sql/sql_error.cc:407
#8  0x00000000005da825 in my_eof (thd=0x7fa89b7d4070) at 10.0/sql/sql_class.h:3816
#9  0x0000000000643f8b in select_send::send_eof (this=0x7fa898aad320) at 10.0/sql/sql_class.cc:2582
#10 0x00000000007cbc2b in Explain_query::send_explain (this=0x7fa898b4af80, thd=0x7fa89b7d4070) at 10.0/sql/sql_explain.cc:147
#11 0x000000000068055a in mysql_execute_command (thd=0x7fa89b7d4070) at 10.0/sql/sql_parse.cc:3556
#12 0x00000000006885a3 in mysql_parse (thd=0x7fa89b7d4070, rawbuf=0x7fa8988e0088 "EXPLAIN INSERT INTO t1 SELECT * FROM t2 UNION SELECT * FROM t3", length=62, parser_state=0x7fa8a23cf600) at 10.0/sql/sql_parse.cc:6529
#13 0x000000000067af8f in dispatch_command (command=COM_QUERY, thd=0x7fa89b7d4070, packet=0x7fa89b7ca071 "", packet_length=62) at 10.0/sql/sql_parse.cc:1308
#14 0x000000000067a275 in do_command (thd=0x7fa89b7d4070) at 10.0/sql/sql_parse.cc:999
#15 0x000000000079826e in do_handle_one_connection (thd_arg=0x7fa89b7d4070) at 10.0/sql/sql_connect.cc:1378
#16 0x0000000000797fcd in handle_one_connection (arg=0x7fa89b7d4070) at 10.0/sql/sql_connect.cc:1293
#17 0x0000000000cd7843 in pfs_spawn_thread (arg=0x7fa89a184370) at 10.0/storage/perfschema/pfs.cc:1860
#18 0x00007fa8a1fc0b50 in start_thread (arg=<optimized out>) at pthread_create.c:304
#19 0x00007fa8a027695d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112

CREATE TABLE t1 (a INT);
CREATE TABLE t2 (b INT);
CREATE TABLE t3 (c INT);
 
# Data is not necessary, tables can be empty as well
INSERT INTO t1 VALUES (1),(2);
INSERT INTO t2 VALUES (3),(4);
INSERT INTO t3 VALUES (5),(6);
 
EXPLAIN INSERT INTO t1 SELECT * FROM t2 UNION SELECT * FROM t3;



 Comments   
Comment by Sergei Petrunia [ 2015-10-05 ]

When I run

EXPLAIN INSERT INTO t1 SELECT * FROM t2

there is no problem. The query calls select_insert::prepare(),
select_insert::prepare2(), but it doesn't call select_insert::send_eof().

When I run

EXPLAIN INSERT INTO t1 SELECT * FROM t2 UNION SELECT * FROM t3;

I see calls to:
select_insert::prepare
select_insert::prepare2
select_insert::send_data
select_insert::send_data
select_insert::send_eof

and then we crash when trying to send EXPLAIN output.

Comment by Sergei Petrunia [ 2015-10-05 ]

The reason for this is as follows:
When running EXPLAIN INSERT ... SELECT UNION SELECT I see that

  • JOIN with select_lex->select_number=1 is executed with (select_options & SELECT_DESCRIBE) != 0
  • JOIN with select_lex->select_number=2 is executed with (select_options & SELECT_DESCRIBE) == 0!
  • JOIN with select_lex->select_number=-1 (this fake_select_lex) is executed with (select_options & SELECT_DESCRIBE) == 0!

I then ran EXPLAIN SELECT * FROM t2 UNION SELECT * FROM test.one_k and there all three joins had (select_options & SELECT_DESCRIBE) != 0.

Comment by Sergei Petrunia [ 2015-10-05 ]

Another difference: with EXPLAIN SELECT * FROM t2 UNION SELECT * FROM test.one_k, all three JOINs have their (select_lex->options & SELECT_DESCRIBE). This is somehow not true for the EXPLAIN INSERT SELECT case.

Comment by Sergei Petrunia [ 2015-10-05 ]

Fix for MDEV-6223 fixes this bug too (See MDEV-6223 for the link).

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