Type:
Bug
Priority:
Critical
Resolution:
Unresolved
Affects Version/s:
N/A
The documentation for the autocommit option mentions:
autocommit influences implicit transactions. An implicit transaction is started when no transaction has been started and a SQL statement is issued which modifies a table.
Along with the list of implicit-commit creating statements implies that a select statement should not retain its locks after execution; however, it does. See the following MTR test and output.
Test:
--source include/have_metadata_lock_info.inc
create table t1 (a int);
insert into t1 values (1);
--echo #
--echo # With autocommit=1, no locks exist after the select
set session autocommit=1;
select * from t1;
select * from INFORMATION_SCHEMA.METADATA_LOCK_INFO;
--echo #
--echo # With autocommit=0, the lock exists
set session autocommit=0;
select * from t1;
select * from INFORMATION_SCHEMA.METADATA_LOCK_INFO;
show variables like 'in_transaction';
COMMIT;
select * from INFORMATION_SCHEMA.METADATA_LOCK_INFO;
Output:
create table t1 (a int);
insert into t1 values (1);
#
# With autocommit=1, no locks exist after the select
set session autocommit=1;
select * from t1;
a
1
select * from INFORMATION_SCHEMA.METADATA_LOCK_INFO;
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
#
# With autocommit=0, the lock exists
set session autocommit=0;
select * from t1;
a
1
select * from INFORMATION_SCHEMA.METADATA_LOCK_INFO;
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
4 MDL_SHARED_READ NULL Table metadata lock test t1
show variables like 'in_transaction';
Variable_name Value
in_transaction 0
COMMIT;
select * from INFORMATION_SCHEMA.METADATA_LOCK_INFO;
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
If this is intended, there are inconsistencies both in the documentation (read-only behavior is not mentioned), and the behavior of the server itself (in_transaction reports 0, yet there are locks that exist that can only be cleared by a COMMIT/ROLLBACK).
Though a more serious impact of this is in replication. Deadlocks have occurred for users with autocommit=0 because they run read-only queries on tables, that will block DDL events from replicating.
relates to
MDEV-33752
explain update ,.set..select freeze replica with autocommit=0
Stalled
Transition
Time In Source Status
Execution Times
Open
Confirmed
132d 2h 9m
1
{"report":{"fcp":5342.5,"ttfb":943,"pageVisibility":"visible","entityId":126657,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0,"journeyId":"7bbbb383-b188-421a-9a23-f34e99021b9a","navigationType":0,"readyForUser":5459,"redirectCount":0,"resourceLoadedEnd":5183.400000095367,"resourceLoadedStart":1089.5,"resourceTiming":[{"duration":521.2000002861023,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":1089.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1089.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1610.7000002861023,"responseStart":0,"secureConnectionStart":0},{"duration":521.0999999046326,"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":1089.9000000953674,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1089.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1611,"responseStart":0,"secureConnectionStart":0},{"duration":3609.2000002861023,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":1090,"connectEnd":1090,"connectStart":1090,"domainLookupEnd":1090,"domainLookupStart":1090,"fetchStart":1090,"redirectEnd":0,"redirectStart":0,"requestStart":1969.9000000953674,"responseEnd":4699.200000286102,"responseStart":2710,"secureConnectionStart":1090},{"duration":3909.5,"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":1090.2000002861023,"connectEnd":1090.2000002861023,"connectStart":1090.2000002861023,"domainLookupEnd":1090.2000002861023,"domainLookupStart":1090.2000002861023,"fetchStart":1090.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":1970.2000002861023,"responseEnd":4999.700000286102,"responseStart":2878.300000190735,"secureConnectionStart":1090.2000002861023},{"duration":2127.7999997138977,"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":1090.3000001907349,"connectEnd":1090.3000001907349,"connectStart":1090.3000001907349,"domainLookupEnd":1090.3000001907349,"domainLookupStart":1090.3000001907349,"fetchStart":1090.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":1970.4000000953674,"responseEnd":3218.0999999046326,"responseStart":3040.5,"secureConnectionStart":1090.3000001907349},{"duration":2127.300000190735,"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":1090.5999999046326,"connectEnd":1090.5999999046326,"connectStart":1090.5999999046326,"domainLookupEnd":1090.5999999046326,"domainLookupStart":1090.5999999046326,"fetchStart":1090.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":1970.3000001907349,"responseEnd":3217.9000000953674,"responseStart":2981.300000190735,"secureConnectionStart":1090.5999999046326},{"duration":2127.5,"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":1090.8000001907349,"connectEnd":1090.8000001907349,"connectStart":1090.8000001907349,"domainLookupEnd":1090.8000001907349,"domainLookupStart":1090.8000001907349,"fetchStart":1090.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":1970.7000002861023,"responseEnd":3218.300000190735,"responseStart":3041.300000190735,"secureConnectionStart":1090.8000001907349},{"duration":536.9000000953674,"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":1090.9000000953674,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1090.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1627.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":2127.5,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":1091.0999999046326,"connectEnd":1091.0999999046326,"connectStart":1091.0999999046326,"domainLookupEnd":1091.0999999046326,"domainLookupStart":1091.0999999046326,"fetchStart":1091.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":1970.8000001907349,"responseEnd":3218.5999999046326,"responseStart":3124.7000002861023,"secureConnectionStart":1091.0999999046326},{"duration":536.7999997138977,"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":1091.3000001907349,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1091.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1628.0999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":2127.2000002861023,"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":1091.5,"connectEnd":1091.5,"connectStart":1091.5,"domainLookupEnd":1091.5,"domainLookupStart":1091.5,"fetchStart":1091.5,"redirectEnd":0,"redirectStart":0,"requestStart":1971.0999999046326,"responseEnd":3218.7000002861023,"responseStart":3214.7000002861023,"secureConnectionStart":1091.5},{"duration":4090.699999809265,"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":1092.4000000953674,"connectEnd":1092.4000000953674,"connectStart":1092.4000000953674,"domainLookupEnd":1092.4000000953674,"domainLookupStart":1092.4000000953674,"fetchStart":1092.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":2161.7000002861023,"responseEnd":5183.099999904633,"responseStart":5090.099999904633,"secureConnectionStart":1092.4000000953674},{"duration":4090.9000000953674,"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":1092.5,"connectEnd":1092.5,"connectStart":1092.5,"domainLookupEnd":1092.5,"domainLookupStart":1092.5,"fetchStart":1092.5,"redirectEnd":0,"redirectStart":0,"requestStart":2161.9000000953674,"responseEnd":5183.400000095367,"responseStart":5127.300000190735,"secureConnectionStart":1092.5},{"duration":503.59999990463257,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":4935.200000286102,"connectEnd":4935.200000286102,"connectStart":4935.200000286102,"domainLookupEnd":4935.200000286102,"domainLookupStart":4935.200000286102,"fetchStart":4935.200000286102,"redirectEnd":0,"redirectStart":0,"requestStart":4935.200000286102,"responseEnd":5438.800000190735,"responseStart":5438.800000190735,"secureConnectionStart":4935.200000286102},{"duration":367.69999980926514,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":5333.800000190735,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":5333.800000190735,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":5701.5,"responseStart":0,"secureConnectionStart":0}],"fetchStart":1,"domainLookupStart":1,"domainLookupEnd":1,"connectStart":1,"connectEnd":1,"requestStart":93,"responseStart":944,"responseEnd":945,"domLoading":949,"domInteractive":5640,"domContentLoadedEventStart":5640,"domContentLoadedEventEnd":5702,"domComplete":6383,"loadEventStart":6383,"loadEventEnd":6384,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":5594.5},{"name":"bigPipe.sidebar-id.end","time":5595.400000095367},{"name":"bigPipe.activity-panel-pipe-id.start","time":5595.5},{"name":"bigPipe.activity-panel-pipe-id.end","time":5596.300000190735},{"name":"activityTabFullyLoaded","time":5715.300000190735}],"measures":[],"correlationId":"3d1edc57848590","effectiveType":"4g","downlink":9.3,"rtt":0,"serverDuration":114,"dbReadsTimeInMs":18,"dbConnsTimeInMs":27,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}