Type:
Bug
Priority:
Critical
Resolution:
Fixed
Affects Version/s:
10.6
The scenario is the following:
1. trx 1 does semi-consistent read for UPDATE, creates waiting lock.
2. trx 2 executes UPDATE, does deadlock check in lock_wait(), sets trx->lock.was_chosen_as_deadlock_victim for trx 1 in Deadlock::report() just before lock_cancel_waiting_and_release() call.
3. trx 1 checks trx->lock.was_chosen_as_deadlock_victim in lock_trx_handle_wait(), and as it's set, does rollback from row_mysql_handle_errors(). trx_commit_or_rollback_prepare() zeroes out trx->lock.wait_thr.
4. trx 2 executes lock_cancel_waiting_and_release(). lock_wait_end() aborts on checking trx->lock.wait_thr.
The comment of trx->lock.wait_thr says:
que_thr_t* wait_thr; /*!< query thread belonging to this
trx that is in waiting
state. For threads suspended in a
lock wait, this is protected by
lock_sys.latch. Otherwise, this may
only be modified by the thread that is
serving the running transaction. */
And lock_wait() acquires lock_sys.wait_mutex before deadlock check:
mysql_mutex_lock(&lock_sys.wait_mutex);
if (trx->lock.wait_lock)
{
if (Deadlock::check_and_resolve(trx))
{
ut_ad(!trx->lock.wait_lock);
trx->error_state= DB_DEADLOCK;
goto end_wait;
}
}
But lock_sys.wait_mutex is not acquired in the following call stack:
0x00005562572076ca in trx_commit_or_rollback_prepare (trx=0x4a6d5ba30040)
at ./storage/innobase/trx/trx0trx.cc:1507
1507 trx->lock.wait_thr = NULL;
(rr) bt
#0 0x00005562572076ca in trx_commit_or_rollback_prepare (trx=0x4a6d5ba30040)
at ./storage/innobase/trx/trx0trx.cc:1507
#1 0x00005562571e7c38 in trx_rollback_step (thr=0x6160085ce218) at ./storage/innobase/trx/trx0roll.cc:915
#2 0x0000556256ffe0d9 in que_thr_step (thr=0x6160085ce218) at ./storage/innobase/que/que0que.cc:659
#3 0x0000556256ffe430 in que_run_threads_low (thr=0x6160085ce218) at ./storage/innobase/que/que0que.cc:709
#4 0x0000556256ffe5d2 in que_run_threads (thr=0x6160085ce218) at ./storage/innobase/que/que0que.cc:729
#5 0x00005562571e9102 in trx_t::rollback_low (this=0x4a6d5ba30040, savept=0x0)
at ./storage/innobase/trx/trx0roll.cc:124
#6 0x00005562571e3593 in trx_t::rollback (this=0x4a6d5ba30040, savept=0x0)
at ./storage/innobase/trx/trx0roll.cc:176
#7 0x00005562570c0f1b in row_mysql_handle_errors (new_err=0x640000aae430, trx=0x4a6d5ba30040, thr=0x620000241848, savept=0x0)
at ./storage/innobase/row/row0mysql.cc:696
Theoretically, trx_t::mutex could protect trx->lock.wait_thr from racing. It's acquired in trx_rollback_step() before trx_commit_or_rollback_prepare() call, and it's also acquired in lock_cancel_waiting_and_release(). But there is some room between victim->lock.was_chosen_as_deadlock_victim= true assigning and trx->mutex_lock() in lock_cancel_waiting_and_release() call in Deadlock::report(), and this gives the ability to rollback the transaction in parallel thread before transaction mutex is acquired in lock_cancel_waiting_and_release().
By the same reason acquiring lock_sys.mutex in trx_commit_or_rollback_prepare() before trx->lock.wait_thr zeroing out can't solve the issue.
Transition
Time In Source Status
Execution Times
Open
In Progress
12d 21h 7m
1
In Progress
Closed
17d 17h 20m
1
{"report":{"fcp":1565.8999999761581,"ttfb":665.8000000715256,"pageVisibility":"visible","entityId":114919,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"e881db20-739f-433b-b8b0-16548ecdd347","navigationType":0,"readyForUser":1749.8000000715256,"redirectCount":0,"resourceLoadedEnd":1808.3000000715256,"resourceLoadedStart":679.7000000476837,"resourceTiming":[{"duration":310.39999997615814,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":679.7000000476837,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":679.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":990.1000000238419,"responseStart":0,"secureConnectionStart":0},{"duration":310.5,"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":680,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":680,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":990.5,"responseStart":0,"secureConnectionStart":0},{"duration":329.39999997615814,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":680.2000000476837,"connectEnd":680.2000000476837,"connectStart":680.2000000476837,"domainLookupEnd":680.2000000476837,"domainLookupStart":680.2000000476837,"fetchStart":680.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":680.2000000476837,"responseEnd":1009.6000000238419,"responseStart":1009.6000000238419,"secureConnectionStart":680.2000000476837},{"duration":406.90000009536743,"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":680.3999999761581,"connectEnd":680.3999999761581,"connectStart":680.3999999761581,"domainLookupEnd":680.3999999761581,"domainLookupStart":680.3999999761581,"fetchStart":680.3999999761581,"redirectEnd":0,"redirectStart":0,"requestStart":680.3999999761581,"responseEnd":1087.3000000715256,"responseStart":1087.3000000715256,"secureConnectionStart":680.3999999761581},{"duration":411.2999999523163,"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":680.6000000238419,"connectEnd":680.6000000238419,"connectStart":680.6000000238419,"domainLookupEnd":680.6000000238419,"domainLookupStart":680.6000000238419,"fetchStart":680.6000000238419,"redirectEnd":0,"redirectStart":0,"requestStart":680.6000000238419,"responseEnd":1091.8999999761581,"responseStart":1091.8000000715256,"secureConnectionStart":680.6000000238419},{"duration":411.5,"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":680.8000000715256,"connectEnd":680.8000000715256,"connectStart":680.8000000715256,"domainLookupEnd":680.8000000715256,"domainLookupStart":680.8000000715256,"fetchStart":680.8000000715256,"redirectEnd":0,"redirectStart":0,"requestStart":680.8000000715256,"responseEnd":1092.3000000715256,"responseStart":1092.3000000715256,"secureConnectionStart":680.8000000715256},{"duration":411.7000000476837,"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":681,"connectEnd":681,"connectStart":681,"domainLookupEnd":681,"domainLookupStart":681,"fetchStart":681,"redirectEnd":0,"redirectStart":0,"requestStart":681,"responseEnd":1092.7000000476837,"responseStart":1092.7000000476837,"secureConnectionStart":681},{"duration":482.7999999523163,"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":681.2000000476837,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":681.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1164,"responseStart":0,"secureConnectionStart":0},{"duration":411.8000000715256,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":681.3999999761581,"connectEnd":681.3999999761581,"connectStart":681.3999999761581,"domainLookupEnd":681.3999999761581,"domainLookupStart":681.3999999761581,"fetchStart":681.3999999761581,"redirectEnd":0,"redirectStart":0,"requestStart":681.3999999761581,"responseEnd":1093.2000000476837,"responseStart":1093.2000000476837,"secureConnectionStart":681.3999999761581},{"duration":482.7000000476837,"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":681.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":681.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1164.2000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":412.10000002384186,"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":681.6000000238419,"connectEnd":681.6000000238419,"connectStart":681.6000000238419,"domainLookupEnd":681.6000000238419,"domainLookupStart":681.6000000238419,"fetchStart":681.6000000238419,"redirectEnd":0,"redirectStart":0,"requestStart":681.6000000238419,"responseEnd":1093.7000000476837,"responseStart":1093.7000000476837,"secureConnectionStart":681.6000000238419},{"duration":698.6000000238419,"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":682.6000000238419,"connectEnd":682.6000000238419,"connectStart":682.6000000238419,"domainLookupEnd":682.6000000238419,"domainLookupStart":682.6000000238419,"fetchStart":682.6000000238419,"redirectEnd":0,"redirectStart":0,"requestStart":682.6000000238419,"responseEnd":1381.2000000476837,"responseStart":1381.2000000476837,"secureConnectionStart":682.6000000238419},{"duration":1100.5,"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":682.7000000476837,"connectEnd":682.7000000476837,"connectStart":682.7000000476837,"domainLookupEnd":682.7000000476837,"domainLookupStart":682.7000000476837,"fetchStart":682.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":682.7000000476837,"responseEnd":1783.2000000476837,"responseStart":1783.2000000476837,"secureConnectionStart":682.7000000476837},{"duration":215.80000007152557,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1212.5,"connectEnd":1212.5,"connectStart":1212.5,"domainLookupEnd":1212.5,"domainLookupStart":1212.5,"fetchStart":1212.5,"redirectEnd":0,"redirectStart":0,"requestStart":1212.5,"responseEnd":1428.3000000715256,"responseStart":1428.3000000715256,"secureConnectionStart":1212.5},{"duration":324,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":1484.3000000715256,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1484.3000000715256,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1808.3000000715256,"responseStart":0,"secureConnectionStart":0},{"duration":308.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":1485.3000000715256,"connectEnd":1485.3000000715256,"connectStart":1485.3000000715256,"domainLookupEnd":1485.3000000715256,"domainLookupStart":1485.3000000715256,"fetchStart":1485.3000000715256,"redirectEnd":0,"redirectStart":0,"requestStart":1485.3000000715256,"responseEnd":1793.8999999761581,"responseStart":1793.8999999761581,"secureConnectionStart":1485.3000000715256},{"duration":316,"initiatorType":"script","name":"https://jira.mariadb.org/s/097ae97cb8fbec7d6ea4bbb1f26955b9-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":1485.8000000715256,"connectEnd":1485.8000000715256,"connectStart":1485.8000000715256,"domainLookupEnd":1485.8000000715256,"domainLookupStart":1485.8000000715256,"fetchStart":1485.8000000715256,"redirectEnd":0,"redirectStart":0,"requestStart":1485.8000000715256,"responseEnd":1801.8000000715256,"responseStart":1801.8000000715256,"secureConnectionStart":1485.8000000715256},{"duration":335.89999997615814,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1550.2000000476837,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1550.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1886.1000000238419,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":477,"responseStart":666,"responseEnd":673,"domLoading":677,"domInteractive":1936,"domContentLoadedEventStart":1936,"domContentLoadedEventEnd":1984,"domComplete":2806,"loadEventStart":2806,"loadEventEnd":2807,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1889.6000000238419},{"name":"bigPipe.sidebar-id.end","time":1890.3999999761581},{"name":"bigPipe.activity-panel-pipe-id.start","time":1890.6000000238419},{"name":"bigPipe.activity-panel-pipe-id.end","time":1892.3000000715256},{"name":"activityTabFullyLoaded","time":2005.3999999761581}],"measures":[],"correlationId":"6670e27b4851b1","effectiveType":"4g","downlink":9.2,"rtt":0,"serverDuration":126,"dbReadsTimeInMs":36,"dbConnsTimeInMs":47,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}