Server hangs on INSERT .. SELECT with derived_merge, FROM subquery, UNION
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MariaDB |
Fix Released
|
Critical
|
Oleksandr "Sanja" Byelkin |
Bug Description
The following query
INSERT INTO t1 SELECT * FROM ( SELECT * FROM t1 ) AS alias UNION SELECT * FROM t2
makes server hang, seemingly forever, if it's run with derived_merge=on (current default).
Reproducible on current maria/5.3 (revno 3521) and maria/5.5 (revno 3402).
On 5.3 it started happening with revno 3421 (works fine on 3420, hangs on 3421).
SELECT without INSERT does not hang.
Minimal optimizer_switch: derived_merge=on
Full optimizer_switch (default): index_merge=
Stack trace while the query is hanging:
#0 0x0000000000724f5a in unique_table (thd=0x1cd4948, table=0x1d59280, table_list=
#1 0x000000000079007f in select_
#2 0x000000000074bb93 in JOIN::prepare (this=0x1d95d40, rref_pointer_
#3 0x0000000000753600 in mysql_select (thd=0x1cd4948, rref_pointer_
#4 0x00000000008da6da in st_select_
#5 0x00000000008d7f64 in mysql_union (thd=0x1cd4948, lex=0x1cd6d90, result=0x1d8d550, unit=0x1cd6e30, setup_tables_
#6 0x000000000074a1a8 in handle_select (thd=0x1cd4948, lex=0x1cd6d90, result=0x1d8d550, setup_tables_
#7 0x00000000006d0e0a in mysql_execute_
#8 0x00000000006d9b05 in mysql_parse (thd=0x1cd4948, rawbuf=0x1d59130 "INSERT INTO t1 SELECT * FROM ( SELECT * FROM t1 ) AS alias UNION SELECT * FROM t2", length=81, found_semicolon
#9 0x00000000006cb5d5 in dispatch_command (command=COM_QUERY, thd=0x1cd4948, packet=0x1d4fcc9 "INSERT INTO t1 SELECT * FROM ( SELECT * FROM t1 ) AS alias UNION SELECT * FROM t2", packet_length=81) at sql_parse.cc:1228
#10 0x00000000006ca8bc in do_command (thd=0x1cd4948) at sql_parse.cc:923
#11 0x00000000006c7754 in handle_
#12 0x00007f8d83d19efc in start_thread (arg=0x7f8d7a51
#13 0x00007f8d832c159d in clone () at ../sysdeps/
# Test case:
SET optimizer_
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (b INT);
INSERT INTO t2 VALUES (3),(4);
INSERT INTO t1 SELECT * FROM ( SELECT * FROM t1 ) AS alias UNION SELECT * FROM t2;
# End of test case
Changed in maria: | |
status: | New → In Progress |
Changed in maria: | |
status: | In Progress → Fix Committed |
Changed in maria: | |
status: | Fix Committed → Fix Released |