Skip to content

Commit

Permalink
MDEV-25069: Assertion `root->weight >= ...' failed in SEL_ARG::tree_d…
Browse files Browse the repository at this point in the history
…elete #2

Note they key_or() may call tree_delete(), which will cause the weight
asserts to be checked. In order to avoid them from firing, update key1
tree's weight after we've changed key1->some_local_child->next_key_part.

Having done that, do we still need this at the function end:

  /* Re-compute the result tree's weight. */
  key1->update_weight_locally();
?
  • Loading branch information
spetrunia committed Mar 17, 2021
1 parent 7e3806c commit 9c7bd4f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mysql-test/main/range_notembedded.result
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,12 @@ insert into t1 values (1,1,1,1), (2,2,2,2), (3,3,3,3);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 2 NULL 3 Using where
drop table t1;
#
# MDEV-25069: Assertion `root->weight >= ...' failed in SEL_ARG::tree_delete #2
#
SELECT *
FROM mysql.help_relation
WHERE
(help_topic_id < '2' OR help_topic_id != 8 OR help_topic_id < 1) AND
help_keyword_id = help_topic_id;
help_topic_id help_keyword_id
10 changes: 10 additions & 0 deletions mysql-test/main/range_notembedded.test
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,13 @@ WHERE
--enable_query_log

drop table t1;

--echo #
--echo # MDEV-25069: Assertion `root->weight >= ...' failed in SEL_ARG::tree_delete #2
--echo #

SELECT *
FROM mysql.help_relation
WHERE
(help_topic_id < '2' OR help_topic_id != 8 OR help_topic_id < 1) AND
help_keyword_id = help_topic_id;
6 changes: 6 additions & 0 deletions sql/opt_range.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10642,9 +10642,15 @@ key_or(RANGE_OPT_PARAM *param, SEL_ARG *key1,SEL_ARG *key2)
*/
tmp->maybe_flag|= key2_cpy.maybe_flag;
key2_cpy.increment_use_count(key1->use_count+1);

uint old_weight= tmp->next_key_part? tmp->next_key_part->weight: 0;

tmp->next_key_part= key_or(param, tmp->next_key_part,
key2_cpy.next_key_part);

uint new_weight= tmp->next_key_part? tmp->next_key_part->weight: 0;
key1->weight += (new_weight - old_weight);

if (!cmp)
break; // case b: done with this key2 range

Expand Down

0 comments on commit 9c7bd4f

Please sign in to comment.