Skip to content

Commit 6de9101

Browse files
Steinar H. Gundersondahlerlend
authored andcommitted
Bug #30471809: SERVER CRASH WITH SELECT FROM INFORMATION SCHEMA TABLES
Remove the hash_join=off optimizer switch; it causes problems with certain information schema views, and it will go away anyway shortly, when the pre-iterator executor (and thus also BNL) is removed. Change-Id: I3779fbc6be57e7fcf6533a32d538cabf3941e5f4
1 parent 2a45759 commit 6de9101

File tree

10 files changed

+19
-76
lines changed

10 files changed

+19
-76
lines changed

mysql-test/r/hash_join.result

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -916,38 +916,6 @@ SET join_buffer_size = 1024;
916916
SELECT STRAIGHT_JOIN COUNT(*) FROM t1 JOIN t2 ON t1.col1 = t2.col1;
917917
DROP TABLE t1, t2;
918918
SET join_buffer_size = DEFAULT;
919-
# See that the hints for hash join works as expected.
920-
CREATE TABLE t1 (col1 INTEGER);
921-
CREATE TABLE t2 (col1 INTEGER);
922-
# By default, hash join should be used.
923-
EXPLAIN FORMAT=tree SELECT t1.col1 FROM t1, t2;
924-
EXPLAIN
925-
-> Inner hash join (cost=0.70 rows=1)
926-
-> Table scan on t2 (cost=0.35 rows=1)
927-
-> Hash
928-
-> Table scan on t1 (cost=0.35 rows=1)
929-
930-
# Try disabling hash join using the hint.
931-
EXPLAIN FORMAT=tree SELECT /*+ NO_HASH_JOIN(t1, t2) */ t1.col1 FROM t1, t2;
932-
EXPLAIN
933-
<not executable by iterator executor>
934-
935-
# Turn off hash join using the optimizer switch, and then enable it again
936-
# using the hint.
937-
SET optimizer_switch="hash_join=off";
938-
EXPLAIN FORMAT=tree SELECT t1.col1 FROM t1, t2;
939-
EXPLAIN
940-
<not executable by iterator executor>
941-
942-
EXPLAIN FORMAT=tree SELECT /*+ HASH_JOIN(t1, t2) */ t1.col1 FROM t1, t2;
943-
EXPLAIN
944-
-> Inner hash join (cost=0.70 rows=1)
945-
-> Table scan on t2 (cost=0.35 rows=1)
946-
-> Hash
947-
-> Table scan on t1 (cost=0.35 rows=1)
948-
949-
SET optimizer_switch=DEFAULT;
950-
DROP TABLE t1, t2;
951919
#
952920
# Bug#29964536 WL#2241: ASSERTION FAILURE IN
953921
# TEMPTABLE::HANDLER::POSITION() AT SRC/HANDLER.CC

mysql-test/r/kill.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ INSERT INTO t2 SELECT id FROM t1;
5353
SET DEBUG_SYNC= 'thread_end SIGNAL con1_end';
5454
SET DEBUG_SYNC= 'before_acos_function SIGNAL in_sync';
5555
SELECT id FROM t1 WHERE id IN
56-
(SELECT /*+ NO_HASH_JOIN(a,b,c,d) */ DISTINCT a.id FROM t2 a, t2 b, t2 c, t2 d
56+
(SELECT /*+ NO_BNL(a,b,c,d) */ DISTINCT a.id FROM t2 a, t2 b, t2 c, t2 d
5757
GROUP BY ACOS(1/a.id), b.id, c.id, d.id
5858
HAVING a.id BETWEEN 10 AND 20);
5959
SET DEBUG_SYNC= 'now WAIT_FOR in_sync';

mysql-test/r/temptable_disk.result

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ SET @@global.temptable_use_mmap = true;
4949
SELECT @@global.temptable_use_mmap;
5050
@@global.temptable_use_mmap
5151
1
52-
CREATE TABLE t (c VARCHAR(128));
52+
CREATE TABLE t (c LONGBLOB);
5353
INSERT INTO t VALUES
5454
(REPEAT('a', 128)),
5555
(REPEAT('b', 128)),
@@ -59,10 +59,7 @@ ANALYZE TABLE t;
5959
Table Op Msg_type Msg_text
6060
test.t analyze status OK
6161
SET GLOBAL temptable_max_ram = 2097152;
62-
# Disable hash join, since that will trigger the new execution engine,
63-
# which in turn won't do the temporary materialization needed to trigger
64-
# overflow to disk.
65-
SELECT /*+ NO_HASH_JOIN(t1, t2, t3, t4, t5, t6) */ * FROM
62+
SELECT * FROM
6663
t AS t1,
6764
t AS t2,
6865
t AS t3,

mysql-test/r/temptable_fallback.result

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Disable hash join for this test, as it will trigger the new executor.
2-
# The new executor will enable the StreamingIterator in many of the test
3-
# cases, resulting in fewer materializations.
4-
SET optimizer_switch="hash_join=off";
1+
# Disable sorting by addon fields, as that will enable the
2+
# StreamingIterator in many of the test cases, resulting in
3+
# fewer materializations.
4+
SET debug = '+d,filesort_force_sort_row_ids';
55
CREATE TABLE t (c VARCHAR(128));
66
INSERT INTO t VALUES
77
(REPEAT('a', 128)),

mysql-test/t/hash_join.test

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -649,24 +649,6 @@ eval $query;
649649
DROP TABLE t1, t2;
650650
SET join_buffer_size = DEFAULT;
651651

652-
--echo # See that the hints for hash join works as expected.
653-
CREATE TABLE t1 (col1 INTEGER);
654-
CREATE TABLE t2 (col1 INTEGER);
655-
656-
--echo # By default, hash join should be used.
657-
EXPLAIN FORMAT=tree SELECT t1.col1 FROM t1, t2;
658-
659-
--echo # Try disabling hash join using the hint.
660-
EXPLAIN FORMAT=tree SELECT /*+ NO_HASH_JOIN(t1, t2) */ t1.col1 FROM t1, t2;
661-
662-
--echo # Turn off hash join using the optimizer switch, and then enable it again
663-
--echo # using the hint.
664-
SET optimizer_switch="hash_join=off";
665-
EXPLAIN FORMAT=tree SELECT t1.col1 FROM t1, t2;
666-
EXPLAIN FORMAT=tree SELECT /*+ HASH_JOIN(t1, t2) */ t1.col1 FROM t1, t2;
667-
SET optimizer_switch=DEFAULT;
668-
DROP TABLE t1, t2;
669-
670652
--echo #
671653
--echo # Bug#29964536 WL#2241: ASSERTION FAILURE IN
672654
--echo # TEMPTABLE::HANDLER::POSITION() AT SRC/HANDLER.CC

mysql-test/t/kill.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ SET DEBUG_SYNC= 'before_acos_function SIGNAL in_sync';
129129
# 'before_acos_function', because the hash join iterator will materialize a lot
130130
# of data before we get so far.
131131
send SELECT id FROM t1 WHERE id IN
132-
(SELECT /*+ NO_HASH_JOIN(a,b,c,d) */ DISTINCT a.id FROM t2 a, t2 b, t2 c, t2 d
132+
(SELECT /*+ NO_BNL(a,b,c,d) */ DISTINCT a.id FROM t2 a, t2 b, t2 c, t2 d
133133
GROUP BY ACOS(1/a.id), b.id, c.id, d.id
134134
HAVING a.id BETWEEN 10 AND 20);
135135

mysql-test/t/temptable_disk.test

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ SELECT @@global.temptable_use_mmap;
6969
# Test TempTable overflow to disk
7070
#
7171

72-
CREATE TABLE t (c VARCHAR(128));
72+
CREATE TABLE t (c LONGBLOB); # Forces use of temporary table in filesort.
7373

7474
INSERT INTO t VALUES
7575
(REPEAT('a', 128)),
@@ -81,10 +81,7 @@ ANALYZE TABLE t;
8181

8282
SET GLOBAL temptable_max_ram = 2097152;
8383
-- disable_result_log
84-
--echo # Disable hash join, since that will trigger the new execution engine,
85-
--echo # which in turn won't do the temporary materialization needed to trigger
86-
--echo # overflow to disk.
87-
SELECT /*+ NO_HASH_JOIN(t1, t2, t3, t4, t5, t6) */ * FROM
84+
SELECT * FROM
8885
t AS t1,
8986
t AS t2,
9087
t AS t3,

mysql-test/t/temptable_fallback.test

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
# Prepare
99
#
1010

11-
--echo # Disable hash join for this test, as it will trigger the new executor.
12-
--echo # The new executor will enable the StreamingIterator in many of the test
13-
--echo # cases, resulting in fewer materializations.
14-
SET optimizer_switch="hash_join=off";
11+
--echo # Disable sorting by addon fields, as that will enable the
12+
--echo # StreamingIterator in many of the test cases, resulting in
13+
--echo # fewer materializations.
14+
SET debug = '+d,filesort_force_sort_row_ids';
1515

1616
CREATE TABLE t (c VARCHAR(128));
1717

sql/filesort.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ void Sort_param::decide_addon_fields(Filesort *file_sort, TABLE *table,
167167
return;
168168
}
169169

170+
DBUG_EXECUTE_IF("filesort_force_sort_row_ids", {
171+
m_addon_fields_status = Addon_fields_status::keep_rowid;
172+
return;
173+
});
174+
170175
// Generally, prefer using addon fields (ie., sorting rows instead of just
171176
// row IDs) if we can.
172177
//

sql/sql_join_buffer.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -674,12 +674,6 @@ int JOIN_CACHE_BNL::init() {
674674
}
675675

676676
bool JOIN_CACHE_BNL::can_be_replaced_with_hash_join() const {
677-
if (!hint_table_state(join->thd, qep_tab->table_ref, HASH_JOIN_HINT_ENUM,
678-
OPTIMIZER_SWITCH_HASH_JOIN)) {
679-
// Disabled by optimizer switch.
680-
return false;
681-
}
682-
683677
if (qep_tab->last_inner() != NO_PLAN_IDX) {
684678
// Outer join.
685679
return false;

0 commit comments

Comments
 (0)