After the following commit:
commit 1748a31ae8d69e4939336f644f884e9de3039e7f
|
Author: Marko Mäkelä <marko.makela@mariadb.com>
|
Date: Tue Jul 3 15:10:06 2018 +0300
|
MDEV-16675 Unnecessary explicit lock acquisition during UPDATE or DELETE
|
|
lock_rec_convert_impl_to_expl() does not create explicit lock if the caller holds implicit lock.
Suppose we have the following call stack:
▾ lock_rec_convert_impl_to_expl
|
▾ lock_clust_rec_read_check_and_lock
|
▾ sel_set_rec_lock
|
▸ row_search_mvcc
|
If lock type is LOCK_GAP or LOCK_ORDINARY, and the transaction holds implicit lock for the record, then explicit gap-lock will not be set for the record, as lock_rec_convert_impl_to_expl() returns true and lock_rec_convert_impl_to_expl() bypasses lock_rec_lock() call.
The following test shows the issue:
--source include/have_innodb.inc
|
--source include/count_sessions.inc
|
CREATE TABLE t(a INT UNSIGNED PRIMARY KEY) ENGINE=InnoDB;
|
INSERT INTO t VALUES (10), (30);
|
--connect (con1,localhost,root,,)
|
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
|
BEGIN;
|
INSERT INTO t VALUES (20);
|
SELECT * FROM t WHERE a BETWEEN 10 AND 30;
|
--connection default
|
SET session innodb_lock_wait_timeout=1;
|
--error ER_LOCK_WAIT_TIMEOUT
|
INSERT INTO t VALUES (15);
|
--disconnect con1
|
DROP TABLE t;
|
--source include/wait_until_count_sessions.inc
|
{"report":{"fcp":847.9000000953674,"ttfb":255.79999995231628,"pageVisibility":"visible","entityId":101418,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"8e3607ae-0a5a-4306-bdc1-594ce55d7bf9","navigationType":0,"readyForUser":911.9000000953674,"redirectCount":0,"resourceLoadedEnd":904.2000000476837,"resourceLoadedStart":288,"resourceTiming":[{"duration":47.200000047683716,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":288,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":288,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":335.2000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":47.799999952316284,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/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","startTime":288.2999999523163,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":288.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":336.09999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":102.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":288.40000009536743,"connectEnd":288.40000009536743,"connectStart":288.40000009536743,"domainLookupEnd":288.40000009536743,"domainLookupStart":288.40000009536743,"fetchStart":288.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":288.40000009536743,"responseEnd":390.59999990463257,"responseStart":390.59999990463257,"secureConnectionStart":288.40000009536743},{"duration":174.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/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","startTime":288.40000009536743,"connectEnd":288.40000009536743,"connectStart":288.40000009536743,"domainLookupEnd":288.40000009536743,"domainLookupStart":288.40000009536743,"fetchStart":288.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":288.40000009536743,"responseEnd":463,"responseStart":463,"secureConnectionStart":288.40000009536743},{"duration":178.20000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":288.59999990463257,"connectEnd":288.59999990463257,"connectStart":288.59999990463257,"domainLookupEnd":288.59999990463257,"domainLookupStart":288.59999990463257,"fetchStart":288.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":288.59999990463257,"responseEnd":466.7999999523163,"responseStart":466.7999999523163,"secureConnectionStart":288.59999990463257},{"duration":178.70000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":288.7000000476837,"connectEnd":288.7000000476837,"connectStart":288.7000000476837,"domainLookupEnd":288.7000000476837,"domainLookupStart":288.7000000476837,"fetchStart":288.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":288.7000000476837,"responseEnd":467.40000009536743,"responseStart":467.40000009536743,"secureConnectionStart":288.7000000476837},{"duration":179.90000009536743,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":288.7999999523163,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":288.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":468.7000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":179.20000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":288.7999999523163,"connectEnd":288.7999999523163,"connectStart":288.7999999523163,"domainLookupEnd":288.7999999523163,"domainLookupStart":288.7999999523163,"fetchStart":288.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":288.7999999523163,"responseEnd":468,"responseStart":468,"secureConnectionStart":288.7999999523163},{"duration":179.70000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":289,"connectEnd":289,"connectStart":289,"domainLookupEnd":289,"domainLookupStart":289,"fetchStart":289,"redirectEnd":0,"redirectStart":0,"requestStart":289,"responseEnd":468.7000000476837,"responseStart":468.7000000476837,"secureConnectionStart":289},{"duration":180.40000009536743,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/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":289.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":289.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":469.5,"responseStart":0,"secureConnectionStart":0},{"duration":180.40000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/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":289.2999999523163,"connectEnd":289.2999999523163,"connectStart":289.2999999523163,"domainLookupEnd":289.2999999523163,"domainLookupStart":289.2999999523163,"fetchStart":289.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":289.2999999523163,"responseEnd":469.7000000476837,"responseStart":469.7000000476837,"secureConnectionStart":289.2999999523163},{"duration":324.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":290,"connectEnd":290,"connectStart":290,"domainLookupEnd":290,"domainLookupStart":290,"fetchStart":290,"redirectEnd":0,"redirectStart":0,"requestStart":290,"responseEnd":614.5999999046326,"responseStart":614.5999999046326,"secureConnectionStart":290},{"duration":614.1000001430511,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":290.09999990463257,"connectEnd":290.09999990463257,"connectStart":290.09999990463257,"domainLookupEnd":290.09999990463257,"domainLookupStart":290.09999990463257,"fetchStart":290.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":290.09999990463257,"responseEnd":904.2000000476837,"responseStart":904.2000000476837,"secureConnectionStart":290.09999990463257},{"duration":242.10000014305115,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":605.7999999523163,"connectEnd":605.7999999523163,"connectStart":605.7999999523163,"domainLookupEnd":605.7999999523163,"domainLookupStart":605.7999999523163,"fetchStart":605.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":605.7999999523163,"responseEnd":847.9000000953674,"responseStart":847.9000000953674,"secureConnectionStart":605.7999999523163}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":127,"responseStart":256,"responseEnd":258,"domLoading":286,"domInteractive":974,"domContentLoadedEventStart":974,"domContentLoadedEventEnd":1016,"domComplete":1744,"loadEventStart":1744,"loadEventEnd":1746,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":955.7999999523163},{"name":"bigPipe.sidebar-id.end","time":956.5999999046326},{"name":"bigPipe.activity-panel-pipe-id.start","time":956.7000000476837},{"name":"bigPipe.activity-panel-pipe-id.end","time":959.0999999046326},{"name":"activityTabFullyLoaded","time":1023.0999999046326}],"measures":[],"correlationId":"1af204b712bff8","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":76,"dbReadsTimeInMs":16,"dbConnsTimeInMs":23,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}