Skip to content

Commit 1225991

Browse files
committed
Bug#35878975: mysqld crash - Assertion failure in OverflowBitset::Or
at overflow_bitset.h An assertion failure in seen when executing certain queries with a degenerate outer join condition. There is some code in the hypergraph optimizer that massages the access path tree if it contains certain degenerate join conditions, so that HeatWave is able to cope with them. In particular, HeatWave does not accept left outer joins if the join condition references tables on the right side only. The hypergraph optimizer usually tries to push such conditions further down, but sometimes it doesn't have anywhere to push them, and leaves them as the join conditions they were originally specified as. A workaround for HeatWave detects these conditions during planning, and manually moves them from the join condition to a filter just below the join. The workaround failed to copy some bit sets from the original access path to the injected filter access paths. Those bit sets are usually empty when the workaround is applied, but when they are not copied, the filter path ends up having empty inlined OverflowBitSets even if the number of predicates in the query exceeds the capacity of inlined bit sets (63). This leads to assertion failures later in the planning when the optimizer expects the bit sets to have big enough capacity to hold one bit per predicate in the query. Fixed by copying the bit sets from the original path to the filter path. Change-Id: I064df2c5ba6d40664877043d720bef41a4f1ccde
1 parent 1f37a67 commit 1225991

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

mysql-test/suite/secondary_engine/inc/secondary_engine_bugs.inc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,29 @@ SET optimizer_max_subgraph_pairs = DEFAULT;
5454

5555
DROP TABLE t;
5656

57+
--echo #
58+
--echo # Bug#35878975: mysqld crash - Assertion failure in OverflowBitset::Or
59+
--echo # at overflow_bitset.h
60+
--echo #
61+
62+
CREATE TABLE t (x INT) SECONDARY_ENGINE MOCK;
63+
ALTER TABLE t SECONDARY_LOAD;
64+
SELECT 1 FROM t AS t1 LEFT OUTER JOIN t AS t2 LEFT JOIN t AS t3 ON TRUE
65+
ON t3.x <=> 1 AND t2.x <> 1 AND t2.x <> 2 AND t2.x <> 3 AND t2.x <> 4 AND
66+
t2.x <> 5 AND t2.x <> 6 AND t2.x <> 7 AND t2.x <> 8 AND t2.x <> 9 AND
67+
t2.x <> 10 AND t2.x <> 11 AND t2.x <> 12 AND t2.x <> 13 AND t2.x <> 14 AND
68+
t2.x <> 15 AND t2.x <> 16 AND t2.x <> 17 AND t2.x <> 18 AND t2.x <> 19 AND
69+
t2.x <> 20 AND t2.x <> 21 AND t2.x <> 22 AND t2.x <> 23 AND t2.x <> 24 AND
70+
t2.x <> 25 AND t2.x <> 26 AND t2.x <> 27 AND t2.x <> 28 AND t2.x <> 29 AND
71+
t2.x <> 30 AND t2.x <> 31 AND t2.x <> 32 AND t2.x <> 33 AND t2.x <> 34 AND
72+
t2.x <> 35 AND t2.x <> 36 AND t2.x <> 37 AND t2.x <> 38 AND t2.x <> 39 AND
73+
t2.x <> 40 AND t2.x <> 41 AND t2.x <> 42 AND t2.x <> 43 AND t2.x <> 44 AND
74+
t2.x <> 45 AND t2.x <> 46 AND t2.x <> 47 AND t2.x <> 48 AND t2.x <> 49 AND
75+
t2.x <> 50 AND t2.x <> 51 AND t2.x <> 52 AND t2.x <> 53 AND t2.x <> 54 AND
76+
t2.x <> 55 AND t2.x <> 56 AND t2.x <> 57 AND t2.x <> 58 AND t2.x <> 59 AND
77+
t2.x <> 60 AND t2.x <> 61 AND t2.x <> 62 AND t2.x <> 63 AND t2.x <> 64;
78+
DROP TABLE t;
79+
5780
--disable_query_log
5881
UNINSTALL PLUGIN mock;
5982
--enable_query_log

mysql-test/suite/secondary_engine/r/secondary_engine_bugs.result

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,25 @@ u AS u3 NATURAL JOIN u AS u4;
5555
x
5656
SET optimizer_max_subgraph_pairs = DEFAULT;
5757
DROP TABLE t;
58+
#
59+
# Bug#35878975: mysqld crash - Assertion failure in OverflowBitset::Or
60+
# at overflow_bitset.h
61+
#
62+
CREATE TABLE t (x INT) SECONDARY_ENGINE MOCK;
63+
ALTER TABLE t SECONDARY_LOAD;
64+
SELECT 1 FROM t AS t1 LEFT OUTER JOIN t AS t2 LEFT JOIN t AS t3 ON TRUE
65+
ON t3.x <=> 1 AND t2.x <> 1 AND t2.x <> 2 AND t2.x <> 3 AND t2.x <> 4 AND
66+
t2.x <> 5 AND t2.x <> 6 AND t2.x <> 7 AND t2.x <> 8 AND t2.x <> 9 AND
67+
t2.x <> 10 AND t2.x <> 11 AND t2.x <> 12 AND t2.x <> 13 AND t2.x <> 14 AND
68+
t2.x <> 15 AND t2.x <> 16 AND t2.x <> 17 AND t2.x <> 18 AND t2.x <> 19 AND
69+
t2.x <> 20 AND t2.x <> 21 AND t2.x <> 22 AND t2.x <> 23 AND t2.x <> 24 AND
70+
t2.x <> 25 AND t2.x <> 26 AND t2.x <> 27 AND t2.x <> 28 AND t2.x <> 29 AND
71+
t2.x <> 30 AND t2.x <> 31 AND t2.x <> 32 AND t2.x <> 33 AND t2.x <> 34 AND
72+
t2.x <> 35 AND t2.x <> 36 AND t2.x <> 37 AND t2.x <> 38 AND t2.x <> 39 AND
73+
t2.x <> 40 AND t2.x <> 41 AND t2.x <> 42 AND t2.x <> 43 AND t2.x <> 44 AND
74+
t2.x <> 45 AND t2.x <> 46 AND t2.x <> 47 AND t2.x <> 48 AND t2.x <> 49 AND
75+
t2.x <> 50 AND t2.x <> 51 AND t2.x <> 52 AND t2.x <> 53 AND t2.x <> 54 AND
76+
t2.x <> 55 AND t2.x <> 56 AND t2.x <> 57 AND t2.x <> 58 AND t2.x <> 59 AND
77+
t2.x <> 60 AND t2.x <> 61 AND t2.x <> 62 AND t2.x <> 63 AND t2.x <> 64;
78+
1
79+
DROP TABLE t;

mysql-test/suite/secondary_engine/r/secondary_engine_bugs_hypergraph.result

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,25 @@ u AS u3 NATURAL JOIN u AS u4;
5252
x
5353
SET optimizer_max_subgraph_pairs = DEFAULT;
5454
DROP TABLE t;
55+
#
56+
# Bug#35878975: mysqld crash - Assertion failure in OverflowBitset::Or
57+
# at overflow_bitset.h
58+
#
59+
CREATE TABLE t (x INT) SECONDARY_ENGINE MOCK;
60+
ALTER TABLE t SECONDARY_LOAD;
61+
SELECT 1 FROM t AS t1 LEFT OUTER JOIN t AS t2 LEFT JOIN t AS t3 ON TRUE
62+
ON t3.x <=> 1 AND t2.x <> 1 AND t2.x <> 2 AND t2.x <> 3 AND t2.x <> 4 AND
63+
t2.x <> 5 AND t2.x <> 6 AND t2.x <> 7 AND t2.x <> 8 AND t2.x <> 9 AND
64+
t2.x <> 10 AND t2.x <> 11 AND t2.x <> 12 AND t2.x <> 13 AND t2.x <> 14 AND
65+
t2.x <> 15 AND t2.x <> 16 AND t2.x <> 17 AND t2.x <> 18 AND t2.x <> 19 AND
66+
t2.x <> 20 AND t2.x <> 21 AND t2.x <> 22 AND t2.x <> 23 AND t2.x <> 24 AND
67+
t2.x <> 25 AND t2.x <> 26 AND t2.x <> 27 AND t2.x <> 28 AND t2.x <> 29 AND
68+
t2.x <> 30 AND t2.x <> 31 AND t2.x <> 32 AND t2.x <> 33 AND t2.x <> 34 AND
69+
t2.x <> 35 AND t2.x <> 36 AND t2.x <> 37 AND t2.x <> 38 AND t2.x <> 39 AND
70+
t2.x <> 40 AND t2.x <> 41 AND t2.x <> 42 AND t2.x <> 43 AND t2.x <> 44 AND
71+
t2.x <> 45 AND t2.x <> 46 AND t2.x <> 47 AND t2.x <> 48 AND t2.x <> 49 AND
72+
t2.x <> 50 AND t2.x <> 51 AND t2.x <> 52 AND t2.x <> 53 AND t2.x <> 54 AND
73+
t2.x <> 55 AND t2.x <> 56 AND t2.x <> 57 AND t2.x <> 58 AND t2.x <> 59 AND
74+
t2.x <> 60 AND t2.x <> 61 AND t2.x <> 62 AND t2.x <> 63 AND t2.x <> 64;
75+
1
76+
DROP TABLE t;

sql/join_optimizer/join_optimizer.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3683,6 +3683,8 @@ void MoveDegenerateJoinConditionToFilter(THD *thd, Query_block *query_block,
36833683
Item *filter_cond = CreateConjunction(&conds);
36843684
AccessPath *filter_path = NewFilterAccessPath(thd, *right_path, filter_cond);
36853685
CopyBasicProperties(**right_path, filter_path);
3686+
filter_path->filter_predicates = (*right_path)->filter_predicates;
3687+
filter_path->delayed_predicates = (*right_path)->delayed_predicates;
36863688
filter_path->set_num_output_rows(filter_path->num_output_rows() *
36873689
(*edge)->selectivity);
36883690
filter_path->set_cost(filter_path->cost() +

0 commit comments

Comments
 (0)