Commit graph

6 commits

Author SHA1 Message Date
Sergei Petrunia
3b071bad19 MDEV-29242: Assertion `computed_weight == weight' failed SEL_ARG::verify_weight
Make SEL_ARG::make_root() maintain SEL_ARG::weight.

Also, an unrelated change: fix dbug_print_sel_arg() to correctly
print SQL NULL for the right endpoint.
2022-08-04 17:10:20 +03:00
Sergei Petrunia
9c7bd4f283 MDEV-25069: Assertion `root->weight >= ...' failed in SEL_ARG::tree_delete #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();
?
2021-03-17 20:59:30 +03:00
Sergei Petrunia
f83e2ecc50 MDEV-24953: 10.5.9 crashes with large IN() list
The problem was in and_all_keys(), the code of MDEV-9759 which calculates
the new tree weight:

First, it didn't take into account the case when

(next->next_key_part=tmp) == NULL

and dereferenced a NULL pointer when getting tmp->weight.

Second, "if (param->alloced_sel_args > SEL_ARG::MAX_SEL_ARGS) break"
could leave the loop with incorrect value of weight.

Fixed by introducing SEL_ARG::update_weight_locally() and calling it
at the end of the function. This allows to avoid caring about all the
above cases.
2021-02-24 14:15:37 +03:00
Sergei Petrunia
73c43ee9ed MDEV-24739: Assertion `root->weight >= ...' failed in SEL_ARG::tree_delete
Also update the SEL_ARG graph weight in:
- sel_add()
- SEL_ARG::clone()

Make key_{and,or}_with_limit() to also verify weight for the arguments
(There is no single point to verify SEL_ARG graphs constructed from
conditions that are not AND-OR formulas, so we hope that those are
connected with AND/OR and do it here).
2021-01-30 00:54:21 +03:00
Sergei Petrunia
c36720388d MDEV-9750: Quick memory exhaustion with 'extended_keys=on' ...
(Variant #5, full patch, for 10.5)

Do not produce SEL_ARG graphs that would yield huge numbers of ranges.
Introduce a concept of SEL_ARG graph's "weight". If we are about to
produce a graph whose "weight" exceeds the limit, remove the parts
of SEL_ARG graph that represent the biggest key parts. Do so until
the graph's is within the limit.

Includes
- debug code to verify SEL_ARG graph weight
- A user-visible @@optimizer_max_sel_arg_weight to control the optimization
- Logging the optimization into the optimizer trace.
2021-01-29 16:20:57 +03:00
Sergei Petrunia
dcc7f93965 MDEV-21958: Query having many NOT-IN clauses running forever, part 3
Add the new file
2020-12-11 22:45:54 +03:00