Part of query which crashes performs a JOIN of a real InnoDB table with a temporary table generated via CTE earlier in the query. The ON condition directly compares like columns from the real table to like columns from the temporary table with =. There are four such comparisons in the ON clause, joined together via AND logic.
Note that removing any one of the comparisons from the ON conditional returns NULL and avoids a crash. Due to the nature of AND, we expect the result of all four conditions being evaluated to also be NULL. Database is crashing while attempting to evaluate a condition it does not need to return a valid result for the given query.
Attachments
Issue Links
is duplicated by
MDEV-25442Lateral derived optimization causes signal 11 crash in CTE query and sometimes reports index corruption.
Closed
relates to
MDEV-23192Crash in row_search_mvcc() probably related to secondary index corruption
Why does LATERAL DERIVED optimization pick KEY(a), not KEY(a,b) ?
Why does it need to do sorting at all? The subquery enumerating one GROUPBY group, so sorting should not be necessary at all?
Should sorting code avoid using keys for which KEYUSE objects are disabled? Or should all KEYUSEs be enabled?
Sergei Petrunia
added a comment - Questions:
Why does LATERAL DERIVED optimization pick KEY(a), not KEY(a,b) ?
Why does it need to do sorting at all? The subquery enumerating one GROUPBY group, so sorting should not be necessary at all?
Should sorting code avoid using keys for which KEYUSE objects are disabled? Or should all KEYUSEs be enabled?
On a side note, optimizer trace does not cover LATERAL DERIVED optimization at all. This is a gap in the optimizer trace and it should be fixed. (Filed MDEV-24325 for this)
Sergei Petrunia
added a comment - - edited On a side note, optimizer trace does not cover LATERAL DERIVED optimization at all. This is a gap in the optimizer trace and it should be fixed. (Filed MDEV-24325 for this)
Why does LATERAL DERIVED optimization pick KEY(a), not KEY(a,b) ?
This is because column a can be "bound" by the top select with the equality "t1.a=cte.a", while column "b" cannot be.
Why does it need to do sorting at all? The subquery enumerating one GROUPBY group, so sorting should not be necessary at all?
As t1.b is not bound, the subquery will enumerate multiple GROUP BY groups.
Sorting is not necessary though, as grouping is done using temp.table (and not by the sort-then-group algorithm)
Should sorting code avoid using keys for which KEYUSE objects are disabled? Or should all KEYUSEs be enabled?
This query tries to switch from KEY(a) to KEY(a,b) while the plan to do splitting assumes KEY(a) is used.
We should either A. make adjustments to the splitting choice, or B. disallow changing the used index in such cases.
Sergei Petrunia
added a comment - Taking another look at this.
Why does LATERAL DERIVED optimization pick KEY(a), not KEY(a,b) ?
This is because column a can be "bound" by the top select with the equality "t1.a=cte.a", while column "b" cannot be.
Why does it need to do sorting at all? The subquery enumerating one GROUPBY group, so sorting should not be necessary at all?
As t1.b is not bound, the subquery will enumerate multiple GROUP BY groups.
Sorting is not necessary though, as grouping is done using temp.table (and not by the sort-then-group algorithm)
Should sorting code avoid using keys for which KEYUSE objects are disabled? Or should all KEYUSEs be enabled?
This query tries to switch from KEY(a) to KEY(a,b) while the plan to do splitting assumes KEY(a) is used.
We should either A. make adjustments to the splitting choice, or B. disallow changing the used index in such cases.
Ok to push into 10.3 after addressing the notes in the review feedback sent by email in:
"Review feedback for the fix of MDEV-23723".
Igor Babaev (Inactive)
added a comment - Ok to push into 10.3 after addressing the notes in the review feedback sent by email in:
"Review feedback for the fix of MDEV-23723 ".
People
Sergei Petrunia
Rob Schwyzer (Inactive)
Votes:
0Vote for this issue
Watchers:
8Start 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":888.2000002861023,"ttfb":245.09999990463257,"pageVisibility":"visible","entityId":91654,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"91062c30-ced6-402f-9d5c-caf9d09e8a20","navigationType":0,"readyForUser":977,"redirectCount":0,"resourceLoadedEnd":612,"resourceLoadedStart":264.59999990463257,"resourceTiming":[{"duration":19.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":264.59999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":264.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":284.09999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":19.800000190734863,"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":264.90000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":264.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":284.7000002861023,"responseStart":0,"secureConnectionStart":0},{"duration":191.2000002861023,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":265.09999990463257,"connectEnd":265.09999990463257,"connectStart":265.09999990463257,"domainLookupEnd":265.09999990463257,"domainLookupStart":265.09999990463257,"fetchStart":265.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":291.59999990463257,"responseEnd":456.30000019073486,"responseStart":319.5,"secureConnectionStart":265.09999990463257},{"duration":346.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":265.30000019073486,"connectEnd":265.30000019073486,"connectStart":265.30000019073486,"domainLookupEnd":265.30000019073486,"domainLookupStart":265.30000019073486,"fetchStart":265.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":293.09999990463257,"responseEnd":612,"responseStart":324.40000009536743,"secureConnectionStart":265.30000019073486},{"duration":61.69999980926514,"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":265.40000009536743,"connectEnd":265.40000009536743,"connectStart":265.40000009536743,"domainLookupEnd":265.40000009536743,"domainLookupStart":265.40000009536743,"fetchStart":265.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":293.30000019073486,"responseEnd":327.09999990463257,"responseStart":325.09999990463257,"secureConnectionStart":265.40000009536743},{"duration":65.7000002861023,"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":265.59999990463257,"connectEnd":265.59999990463257,"connectStart":265.59999990463257,"domainLookupEnd":265.59999990463257,"domainLookupStart":265.59999990463257,"fetchStart":265.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":293.5,"responseEnd":331.30000019073486,"responseStart":328.09999990463257,"secureConnectionStart":265.59999990463257},{"duration":65.90000009536743,"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":265.80000019073486,"connectEnd":265.80000019073486,"connectStart":265.80000019073486,"domainLookupEnd":265.80000019073486,"domainLookupStart":265.80000019073486,"fetchStart":265.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":293.7000002861023,"responseEnd":331.7000002861023,"responseStart":328.7000002861023,"secureConnectionStart":265.80000019073486},{"duration":25.200000286102295,"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":266.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":266.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":291.30000019073486,"responseStart":0,"secureConnectionStart":0},{"duration":73.89999961853027,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":266.2000002861023,"connectEnd":266.2000002861023,"connectStart":266.2000002861023,"domainLookupEnd":266.2000002861023,"domainLookupStart":266.2000002861023,"fetchStart":266.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":299.59999990463257,"responseEnd":340.09999990463257,"responseStart":337.59999990463257,"secureConnectionStart":266.2000002861023},{"duration":32.5,"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":266.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":266.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":299,"responseStart":0,"secureConnectionStart":0},{"duration":88.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":266.59999990463257,"connectEnd":266.59999990463257,"connectStart":266.59999990463257,"domainLookupEnd":266.59999990463257,"domainLookupStart":266.59999990463257,"fetchStart":266.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":308.2000002861023,"responseEnd":355.09999990463257,"responseStart":343.59999990463257,"secureConnectionStart":266.59999990463257},{"duration":290.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":267.5,"connectEnd":267.5,"connectStart":267.5,"domainLookupEnd":267.5,"domainLookupStart":267.5,"fetchStart":267.5,"redirectEnd":0,"redirectStart":0,"requestStart":342,"responseEnd":557.9000000953674,"responseStart":552.4000000953674,"secureConnectionStart":267.5},{"duration":291.90000009536743,"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":267.59999990463257,"connectEnd":267.59999990463257,"connectStart":267.59999990463257,"domainLookupEnd":267.59999990463257,"domainLookupStart":267.59999990463257,"fetchStart":267.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":348.30000019073486,"responseEnd":559.5,"responseStart":554.5,"secureConnectionStart":267.59999990463257},{"duration":53.700000286102295,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":610,"connectEnd":610,"connectStart":610,"domainLookupEnd":610,"domainLookupStart":610,"fetchStart":610,"redirectEnd":0,"redirectStart":0,"requestStart":629.9000000953674,"responseEnd":663.7000002861023,"responseStart":662.8000001907349,"secureConnectionStart":610},{"duration":256,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":840.8000001907349,"connectEnd":840.8000001907349,"connectStart":840.8000001907349,"domainLookupEnd":840.8000001907349,"domainLookupStart":840.8000001907349,"fetchStart":840.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":1065.8000001907349,"responseEnd":1096.8000001907349,"responseStart":1096,"secureConnectionStart":840.8000001907349},{"duration":197.5,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":881.4000000953674,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":881.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1078.9000000953674,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":66,"responseStart":245,"responseEnd":248,"domLoading":262,"domInteractive":1086,"domContentLoadedEventStart":1086,"domContentLoadedEventEnd":1143,"domComplete":1429,"loadEventStart":1429,"loadEventEnd":1430,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1061},{"name":"bigPipe.sidebar-id.end","time":1061.8000001907349},{"name":"bigPipe.activity-panel-pipe-id.start","time":1061.9000000953674},{"name":"bigPipe.activity-panel-pipe-id.end","time":1063.5},{"name":"activityTabFullyLoaded","time":1166.0999999046326}],"measures":[],"correlationId":"6e3c600dde1e58","effectiveType":"4g","downlink":9.7,"rtt":0,"serverDuration":99,"dbReadsTimeInMs":13,"dbConnsTimeInMs":22,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Questions: