Core was generated by `/test/MD121221-mariadb-10.7.2-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGABRT, Aborted.
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
[Current thread is 1 (Thread 0x14e8a0d6e700 (LWP 3592433))]
(gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1 0x000014e8abfd2859 in __GI_abort () at abort.c:79
#2 0x000014e8abfd2729 in __assert_fail_base (fmt=0x14e8ac168588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5645bb249e18 "got_name == named_item_expected()", file=0x5645bb249d20 "/test/10.7_dbg/sql/my_json_writer.cc", line=42, function=<optimized out>) at assert.c:92
#3 0x000014e8abfe3f36 in __GI___assert_fail (assertion=assertion@entry=0x5645bb249e18 "got_name == named_item_expected()", file=file@entry=0x5645bb249d20 "/test/10.7_dbg/sql/my_json_writer.cc", line=line@entry=42, function=function@entry=0x5645bb249f18 "void Json_writer::on_start_object()") at assert.c:101
#4 0x00005645ba72ab95 in Json_writer::on_start_object (this=0x5645bcecb130) at /test/10.7_dbg/sql/my_json_writer.cc:42
#5 Json_writer::start_object (this=this@entry=0x5645bcecb130) at /test/10.7_dbg/sql/my_json_writer.cc:51
#6 0x00005645ba5c744d in Json_writer_object::Json_writer_object (str=0x0, writer=0x5645bcecb130, this=<synthetic pointer>) at /test/10.7_dbg/sql/my_json_writer.h:444
#7 Json_writer_object::Json_writer_object (str=0x0, thd=<optimized out>, this=<synthetic pointer>) at /test/10.7_dbg/sql/my_json_writer.h:449
#8 JOIN::optimize_inner (this=this@entry=0x14e7e0016fd8) at /test/10.7_dbg/sql/sql_select.cc:1986
#9 0x00005645ba5c8e3a in JOIN::optimize (this=0x14e7e0016fd8) at /test/10.7_dbg/sql/sql_select.cc:1809
#10 0x00005645ba9482be in subselect_single_select_engine::exec (this=0x14e7e0015fb0) at /test/10.7_dbg/sql/item_subselect.cc:4034
#11 0x00005645ba947ba6 in Item_subselect::exec (this=this@entry=0x14e7e0015ce0) at /test/10.7_dbg/sql/item_subselect.cc:853
#12 0x00005645ba94d3e9 in Item_in_subselect::exec (this=0x14e7e0015ce0) at /test/10.7_dbg/sql/item_subselect.cc:1035
#13 0x00005645ba946a75 in Item_in_subselect::val_bool (this=0x14e7e0015ce0) at /test/10.7_dbg/sql/item_subselect.cc:1965
#14 0x00005645ba3ecd77 in Item::val_bool_result (this=<optimized out>) at /test/10.7_dbg/sql/item.h:1783
#15 0x00005645ba88e738 in Item_in_optimizer::val_int (this=0x14e7e0017650) at /test/10.7_dbg/sql/item_cmpfunc.cc:1637
#16 0x00005645ba5a50ab in make_join_select (join=join@entry=0x14e7e00168e8, select=0x14e7e00cb820, cond=0x14e7e0017650) at /test/10.7_dbg/sql/sql_select.cc:11727
#17 0x00005645ba5c56dd in JOIN::optimize_stage2 (this=this@entry=0x14e7e00168e8) at /test/10.7_dbg/sql/sql_select.cc:2742
#18 0x00005645ba5c8b47 in JOIN::optimize_inner (this=this@entry=0x14e7e00168e8) at /test/10.7_dbg/sql/sql_select.cc:2479
#19 0x00005645ba5c8e3a in JOIN::optimize (this=this@entry=0x14e7e00168e8) at /test/10.7_dbg/sql/sql_select.cc:1809
#20 0x00005645ba5c94de in mysql_select (thd=thd@entry=0x14e7e0000db8, tables=0x14e7e0014468, fields=@0x14e7e0014128: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14e7e0014420, last = 0x14e7e0014420, elements = 1}, <No data fields>}, conds=0x14e7e0015ce0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x14e7e00168c0, unit=0x14e7e00051c0, select_lex=0x14e7e0013e88) at /test/10.7_dbg/sql/sql_select.cc:4979
#21 0x00005645ba5c97e2 in handle_select (thd=thd@entry=0x14e7e0000db8, lex=lex@entry=0x14e7e00050e8, result=result@entry=0x14e7e00168c0, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.7_dbg/sql/sql_select.cc:545
#22 0x00005645ba528c1e in execute_sqlcom_select (thd=thd@entry=0x14e7e0000db8, all_tables=0x14e7e0014468) at /test/10.7_dbg/sql/sql_parse.cc:6253
#23 0x00005645ba535af1 in mysql_execute_command (thd=thd@entry=0x14e7e0000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.7_dbg/sql/sql_parse.cc:3944
#24 0x00005645ba521e0f in mysql_parse (thd=thd@entry=0x14e7e0000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14e8a0d6d400) at /test/10.7_dbg/sql/sql_parse.cc:8028
#25 0x00005645ba530aab in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14e7e0000db8, packet=packet@entry=0x14e7e000b879 "SELECT a FROM t WHERE (a,b) in (SELECT @c,@d)", packet_length=packet_length@entry=45, blocking=blocking@entry=true) at /test/10.7_dbg/sql/sql_class.h:1360
#26 0x00005645ba533eea in do_command (thd=0x14e7e0000db8, blocking=blocking@entry=true) at /test/10.7_dbg/sql/sql_parse.cc:1402
#27 0x00005645ba6ad902 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5645bceaae48, put_in_cache=put_in_cache@entry=true) at /test/10.7_dbg/sql/sql_connect.cc:1418
#28 0x00005645ba6adf07 in handle_one_connection (arg=arg@entry=0x5645bceaae48) at /test/10.7_dbg/sql/sql_connect.cc:1312
#29 0x00005645bab2e33e in pfs_spawn_thread (arg=0x5645bcdbe738) at /test/10.7_dbg/storage/perfschema/pfs.cc:2201
#30 0x000014e8ac4e1609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#31 0x000014e8ac0cf293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
1. Optimization for select #1 reaches "plan refinement" stage in
make_join_select.
2. It tries to evaluate a constant subquery.
3. It finds out that the subquery has no query plan yet
4. It tries to compute a query plan.
The particularly odd is the combination of #2 and #3.
There are other places in the optimizer where it will evaluate "constant"
items. Does this mean that we need to make sure that for any of these places,
the calling side leaves the Optimizer Trace in the right state (that is, a
state where one can start tracing an optimization?)
Sergei Petrunia
added a comment -
The fix is kind of obvious.
What I find odd is this:
1. Optimization for select #1 reaches "plan refinement" stage in
make_join_select.
2. It tries to evaluate a constant subquery.
3. It finds out that the subquery has no query plan yet
4. It tries to compute a query plan.
The particularly odd is the combination of #2 and #3.
There are other places in the optimizer where it will evaluate "constant"
items. Does this mean that we need to make sure that for any of these places,
the calling side leaves the Optimizer Trace in the right state (that is, a
state where one can start tracing an optimization?)
There is optimize_constant_subqueries() call made from early phase of
JOIN::optimize()... but the subquery is not yet constant at that point.
The subquery should become constant when table t is found to be constant.
This call is made
conds->update_used_tables();
and it partially makes the subquery constant:
conds->used_tables()=0
conds->const_item()= false
const_item=false(), because Item_subselect::const_item_cache remains false...
which happens, because because engine->uncacheable()= UNCACHEABLE_EXPLAIN | UNCACHEABLE_SIDEEFFECT.
and this code doesn't make it non-constant:
void Item_subselect::update_used_tables()
{
if (!forced_const)
{
recalc_used_tables(parent_select, FALSE);
if (!(engine->uncacheable() & ~UNCACHEABLE_EXPLAIN))
{
// did all used tables become static?
if (!(used_tables_cache & ~engine->upper_select_const_tables()) &&
! with_recursive_reference)
const_item_cache= 1;
}
}
}
Sergei Petrunia
added a comment - There is optimize_constant_subqueries() call made from early phase of
JOIN::optimize()... but the subquery is not yet constant at that point.
The subquery should become constant when table t is found to be constant.
This call is made
conds->update_used_tables();
and it partially makes the subquery constant:
conds->used_tables()=0
conds->const_item()= false
const_item=false(), because Item_subselect::const_item_cache remains false...
which happens, because because engine->uncacheable()= UNCACHEABLE_EXPLAIN | UNCACHEABLE_SIDEEFFECT.
and this code doesn't make it non-constant:
void Item_subselect::update_used_tables()
{
if (!forced_const)
{
recalc_used_tables(parent_select, FALSE);
if (!(engine->uncacheable() & ~UNCACHEABLE_EXPLAIN))
{
// did all used tables become static?
if (!(used_tables_cache & ~engine->upper_select_const_tables()) &&
! with_recursive_reference)
const_item_cache= 1;
}
}
}
WHERE t.a < (select max(a) from ten where ten.a+t.a<333);
It doesn't crash.
Reason:
make_join_select() doesn't try to evaluate it, because const_cond->is_expensive()=false.
Item_subselect::is_expensive() returns
1. FALSE for "degenerate" subqueries
2. TRUE when the subquery doesn't have a query plan, yet.
The original query takes path#1, this query takes path#2.
Sergei Petrunia
added a comment - Trying a similar but non-degenerate subquery:
explain
SELECT a FROM t
WHERE t.a < (select max(a) from ten where ten.a+t.a<333);
It doesn't crash.
Reason:
make_join_select() doesn't try to evaluate it, because const_cond->is_expensive()=false.
Item_subselect::is_expensive() returns
1. FALSE for "degenerate" subqueries
2. TRUE when the subquery doesn't have a query plan, yet.
The original query takes path#1, this query takes path#2.
That is, this bug only applies to "degenerate" subqueries.
Other places in the optimizer that call item->val_int() for constant items are not affected because they check the const_item()=true, or can_eval_in_optimize()=true which is even more restrictive than that.
Sergei Petrunia
added a comment - That is, this bug only applies to "degenerate" subqueries.
Other places in the optimizer that call item->val_int() for constant items are not affected because they check the
const_item()=true , or can_eval_in_optimize()=true which is even more restrictive than that.
People
Sergei Petrunia
Roel Van de Paar
Votes:
0Vote for this issue
Watchers:
4Start watching this issue
Dates
Created:
Updated:
Resolved:
Git Integration
Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.
{"report":{"fcp":855.7999997138977,"ttfb":241.2999997138977,"pageVisibility":"visible","entityId":105919,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"61b18b38-b2dd-442e-b706-0580c4e8464a","navigationType":0,"readyForUser":943.7999997138977,"redirectCount":0,"resourceLoadedEnd":587.6999998092651,"resourceLoadedStart":249.90000009536743,"resourceTiming":[{"duration":4.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":249.90000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":249.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":254.40000009536743,"responseStart":0,"secureConnectionStart":0},{"duration":4.400000095367432,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":250.2999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":250.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":254.69999980926514,"responseStart":0,"secureConnectionStart":0},{"duration":203.39999961853027,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":250.40000009536743,"connectEnd":250.40000009536743,"connectStart":250.40000009536743,"domainLookupEnd":250.40000009536743,"domainLookupStart":250.40000009536743,"fetchStart":250.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":258,"responseEnd":453.7999997138977,"responseStart":283,"secureConnectionStart":250.40000009536743},{"duration":336.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":251,"connectEnd":251,"connectStart":251,"domainLookupEnd":251,"domainLookupStart":251,"fetchStart":251,"redirectEnd":0,"redirectStart":0,"requestStart":258.7999997138977,"responseEnd":587.6999998092651,"responseStart":300.59999990463257,"secureConnectionStart":251},{"duration":66.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":251.19999980926514,"connectEnd":251.19999980926514,"connectStart":251.19999980926514,"domainLookupEnd":251.19999980926514,"domainLookupStart":251.19999980926514,"fetchStart":251.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":260.5,"responseEnd":318,"responseStart":317.5,"secureConnectionStart":251.19999980926514},{"duration":65.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":251.5,"connectEnd":251.5,"connectStart":251.5,"domainLookupEnd":251.5,"domainLookupStart":251.5,"fetchStart":251.5,"redirectEnd":0,"redirectStart":0,"requestStart":260.7999997138977,"responseEnd":317.40000009536743,"responseStart":316.2999997138977,"secureConnectionStart":251.5},{"duration":81.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":251.59999990463257,"connectEnd":251.59999990463257,"connectStart":251.59999990463257,"domainLookupEnd":251.59999990463257,"domainLookupStart":251.59999990463257,"fetchStart":251.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":262.59999990463257,"responseEnd":332.90000009536743,"responseStart":332.19999980926514,"secureConnectionStart":251.59999990463257},{"duration":9.400000095367432,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":251.7999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":251.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":261.19999980926514,"responseStart":0,"secureConnectionStart":0},{"duration":80.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":251.90000009536743,"connectEnd":251.90000009536743,"connectStart":251.90000009536743,"domainLookupEnd":251.90000009536743,"domainLookupStart":251.90000009536743,"fetchStart":251.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":264.5,"responseEnd":332.09999990463257,"responseStart":331.40000009536743,"secureConnectionStart":251.90000009536743},{"duration":11,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":252.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":252.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":263.09999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":95.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":252.2999997138977,"connectEnd":252.2999997138977,"connectStart":252.2999997138977,"domainLookupEnd":252.2999997138977,"domainLookupStart":252.2999997138977,"fetchStart":252.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":265.19999980926514,"responseEnd":347.7999997138977,"responseStart":345.59999990463257,"secureConnectionStart":252.2999997138977},{"duration":22.40000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":268.09999990463257,"connectEnd":276,"connectStart":276,"domainLookupEnd":276,"domainLookupStart":276,"fetchStart":268.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":276.5,"responseEnd":290.5,"responseStart":288.7999997138977,"secureConnectionStart":276},{"duration":24.200000286102295,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":268.19999980926514,"connectEnd":268.19999980926514,"connectStart":268.19999980926514,"domainLookupEnd":268.19999980926514,"domainLookupStart":268.19999980926514,"fetchStart":268.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":280.5,"responseEnd":292.40000009536743,"responseStart":291.59999990463257,"secureConnectionStart":268.19999980926514},{"duration":126.5,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":606.4000000953674,"connectEnd":606.4000000953674,"connectStart":606.4000000953674,"domainLookupEnd":606.4000000953674,"domainLookupStart":606.4000000953674,"fetchStart":606.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":693,"responseEnd":732.9000000953674,"responseStart":732.0999999046326,"secureConnectionStart":606.4000000953674},{"duration":280.90000009536743,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":810.0999999046326,"connectEnd":810.0999999046326,"connectStart":810.0999999046326,"domainLookupEnd":810.0999999046326,"domainLookupStart":810.0999999046326,"fetchStart":810.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":1053.2999997138977,"responseEnd":1091,"responseStart":1090.1999998092651,"secureConnectionStart":810.0999999046326},{"duration":259.59999990463257,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":849.5999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":849.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1109.1999998092651,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":31,"domainLookupEnd":40,"connectStart":40,"connectEnd":60,"secureConnectionStart":48,"requestStart":61,"responseStart":241,"responseEnd":267,"domLoading":245,"domInteractive":1046,"domContentLoadedEventStart":1046,"domContentLoadedEventEnd":1103,"domComplete":1650,"loadEventStart":1650,"loadEventEnd":1650,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1020.7999997138977},{"name":"bigPipe.sidebar-id.end","time":1021.5},{"name":"bigPipe.activity-panel-pipe-id.start","time":1021.5999999046326},{"name":"bigPipe.activity-panel-pipe-id.end","time":1023.9000000953674},{"name":"activityTabFullyLoaded","time":1121.6999998092651}],"measures":[],"correlationId":"75fe47ca6dcf1f","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":108,"dbReadsTimeInMs":13,"dbConnsTimeInMs":22,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
The fix is kind of obvious.
What I find odd is this:
1. Optimization for select #1 reaches "plan refinement" stage in
make_join_select.
2. It tries to evaluate a constant subquery.
3. It finds out that the subquery has no query plan yet
4. It tries to compute a query plan.
The particularly odd is the combination of #2 and #3.
There are other places in the optimizer where it will evaluate "constant"
items. Does this mean that we need to make sure that for any of these places,
the calling side leaves the Optimizer Trace in the right state (that is, a
state where one can start tracing an optimization?)