-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
MDEV-35206: Assertion failure in JOIN::dbug_verify_sj_inner_tables #4345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 10.11
Are you sure you want to change the base?
MDEV-35206: Assertion failure in JOIN::dbug_verify_sj_inner_tables #4345
Conversation
921c224
to
60871f9
Compare
60871f9
to
f47aac8
Compare
Technically the fix is correct but it doesn't fix a class of similar problems. There is also I suggest moving initialization of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to address the above.
f47aac8
to
428e80d
Compare
Sure. Made the suggested changes. However, I am not sure if reset_nj_counters() is really required. The test cases have no problem even without making a call to that function. |
When one isn't sure, one should try finding out :-) reset_nj_counters() resets the values of I've made the testcase slightly convoluted and added printouts:
In debugger this looks like this:
... lots of those... note that value of counter <= n_tables .
Ok now we are in the second greedy_search() call:
note that counter > n_tables. This seems wrong. |
428e80d
to
b8a5d1f
Compare
Ah! thanks Sergei for the test case. Added an assert for the provided patch, and removed print statements. |
b8a5d1f
to
f2eec0e
Compare
Now, there are multiple calls:
This calls for moving the call to reset_nj_counters() into initialize_join_maps(). Please do that. Please rename Also, the call to
at the start of choose_plan() is now redundant, please remove. Also, this assignment at start of choose_plan() is now redundant, please remove:
The same goes for this assignment:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting close.
Please address the above.
A nested select query is crashing in when optimizer_join_limit_pref_ratio=10 and optimizer_search_depth=1 due to an assertion failure in JOIN::dbug_verify_sj_inner_tables(). In sql_select.cc#choose_plan(), there are 2 back-2-back calls to greedy_search(). The first one is invoked to build a join plan that can short-cut ORDER BY...LIMIT, while the second invocation to not consider short-cut. The greedy_search() should start with a value of join->cur_sj_inner_tables set to 0. However, the first greedy_search() call left the value of join->cur_sj_inner_tables to "6". This caused the assert to fail in dbug_verify_sj_inner_tables() as soon as the second greedy_search() started, where in it was expecting a value of 0. Similar problem is noticed with cur_embedding_map in the case of nested joins, and nested_join counter. Initialize join->cur_sj_inner_tables, and join->cur_embedding_map to 0, and also invoke reset_nj_counters() during the start of greedy_search(), and optimize_straight_join().
f2eec0e
to
f20c0e5
Compare
MDEV-35206: Assertion failure in JOIN::dbug_verify_sj_inner_tables
A nested select query is crashing in when optimizer_join_limit_pref_ratio=10
and optimizer_search_depth=1 due to an assertion failure in
JOIN::dbug_verify_sj_inner_tables().
In sql_select.cc#choose_plan(), there are 2 back-2-back calls to
greedy_search(). The first one is invoked to build a join plan
that can short-cut ORDER BY...LIMIT, while the second invocation
to not consider short-cut.
The greedy_search() should start with a value of join->cur_sj_inner_tables
set to 0. However, the first greedy_search() call left the value of
join->cur_sj_inner_tables to "6". This caused the assert to fail in
dbug_verify_sj_inner_tables() as soon as the second greedy_search() started,
where in it was expecting a value of 0.
Similar problem is noticed with cur_embedding_map in the case of nested
joins, and nested_join counter.
Initialize join->cur_sj_inner_tables, and join->cur_embedding_map to 0,
and also invoke reset_nj_counters() during the start of greedy_search(),
and optimize_straight_join().