revno: 4053
|
committer: Gopal Shankar <gopal.shankar@oracle.com>
|
branch nick: sf_mysql-5.6
|
timestamp: Fri 2012-07-20 12:25:34 +0530
|
message:
|
Bug#13036505 62540: TABLE LOCKS WITHIN STORED FUNCTIONS ARE BACK IN
|
5.5 WITH MIXED AND ROW BI.
|
|
Problem:-
|
-------
|
SELECT/SET/DO statements that used stored functions but didn't change
|
any data acquired too strong locks on tables used (i.e. read) in these
|
functions if binary logging was on and used statement or mixed mode.
|
For MyISAM tables this resulted in that concurrent insert to such
|
tables were blocked while such a statement was running. For InnoDB
|
tables such statements were using locking reads (and as result blocked
|
any concurrent changes and SELECT ... FOR UPDATE statements) instead
|
of using snapshot isolation.
|
|
Analysis:
|
--------
|
Due to a statement-based replication limitation, statements such as
|
INSERT INTO .. SELECT FROM .. and CREATE TABLE .. SELECT FROM need
|
to grab a TL_READ_NO_INSERT lock on the source table in order to
|
prevent the replication of a concurrent statement that modifies the
|
source table. If such a statement gets applied on the slave before
|
the INSERT .. SELECT statement finishes, data on the master could
|
differ from data on the slave and end-up with a discrepancy between
|
the binary log and table state.
|
|
This also applies to SELECT/SET/DO statements which use stored
|
functions. Calls to such functions are going to be logged as a
|
whole and thus should be serialized against concurrent changes
|
to tables used by those functions. The current implementation
|
does not check if functions only read data and won't be written
|
into binary log as result. Currently we use TL_READ_NO_INSERT lock
|
for all tables used by stored functions called from SELECTs if
|
binary logging is on and uses statement or mixed mode.
|
|
Note that even though InnoDB engine does its own locking it still
|
relies on thr_lock.c locks set by SQL-layer to infer type of
|
row-locks to acquire when reading data. Since TL_READ_NO_INSERT
|
is translated to locking reads in InnoDB the above means that
|
SELECT/SET/DO that uses stored functions will do locking reads
|
on tables used by routines.
|
|
We can use weaker type of lock TL_READ, which will allow concurrent
|
inserts, if a statement only reads data (since such a statement
|
won't get into binary log anyway). For InnoDB this lock will be
|
translated to non-locking, snapshot reads (unless in serializable
|
mode).
|
|
Fix:-
|
---
|
If we know that all stored routines which are going to be called by
|
statement do not change tables we can choose weaker TL_READ lock for
|
tables used by it.
|
|
If some substatement which is added to sp_head modifies data, then
|
we set this flag. This flag is used in read_lock_type_for_table()
|
to choose weaker TL_READ lock for tables.
|
|
Currently open_tables() processes a loop, where it initially
|
processes known tables and routines, and further in each iteration
|
it processes new tables and routines eventually found. Currently
|
the lock upgrade happens within the loop where complete
|
table/routine list for statement is not known, within which
|
we cannot decide if lock upgrade is needed or to be ignored.
|
This fix handles lock upgrade upon loop completion. When the
|
complete list of tables get prepared, we check if there were
|
any SF which write data, if not, we ignore upgrading lock.
|
|
Test case:-
|
--------
|
main.lock_sync and main.innodb_mysql_lock2 test most of above
|
mentioned scenario's. These tests have been updated according
|
to new behavior. A new test case has been added to test
|
SF which modifies temporary table.
|
- is part of
-
MDEV-4784
merge test cases from 5.6
-
-
Stalled
There are no comments yet on this issue.
{"report":{"fcp":952.1999998092651,"ttfb":340.30000019073486,"pageVisibility":"visible","entityId":34803,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"1aa0ed57-9112-4f4d-8cfa-fcf8bd127927","navigationType":0,"readyForUser":1040.1000003814697,"redirectCount":0,"resourceLoadedEnd":1325.6000003814697,"resourceLoadedStart":347.30000019073486,"resourceTiming":[{"duration":69.30000019073486,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":347.30000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":347.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":416.6000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":69.69999980926514,"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":347.6000003814697,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":347.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":417.30000019073486,"responseStart":0,"secureConnectionStart":0},{"duration":128.79999923706055,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":347.9000005722046,"connectEnd":347.9000005722046,"connectStart":347.9000005722046,"domainLookupEnd":347.9000005722046,"domainLookupStart":347.9000005722046,"fetchStart":347.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":347.9000005722046,"responseEnd":476.69999980926514,"responseStart":476.69999980926514,"secureConnectionStart":347.9000005722046},{"duration":205.30000019073486,"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":348,"connectEnd":348,"connectStart":348,"domainLookupEnd":348,"domainLookupStart":348,"fetchStart":348,"redirectEnd":0,"redirectStart":0,"requestStart":348,"responseEnd":553.3000001907349,"responseStart":553.3000001907349,"secureConnectionStart":348},{"duration":208.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":348.30000019073486,"connectEnd":348.30000019073486,"connectStart":348.30000019073486,"domainLookupEnd":348.30000019073486,"domainLookupStart":348.30000019073486,"fetchStart":348.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":348.30000019073486,"responseEnd":557,"responseStart":557,"secureConnectionStart":348.30000019073486},{"duration":208.89999961853027,"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":348.6000003814697,"connectEnd":348.6000003814697,"connectStart":348.6000003814697,"domainLookupEnd":348.6000003814697,"domainLookupStart":348.6000003814697,"fetchStart":348.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":348.6000003814697,"responseEnd":557.5,"responseStart":557.5,"secureConnectionStart":348.6000003814697},{"duration":209.10000038146973,"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":348.80000019073486,"connectEnd":348.80000019073486,"connectStart":348.80000019073486,"domainLookupEnd":348.80000019073486,"domainLookupStart":348.80000019073486,"fetchStart":348.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":348.80000019073486,"responseEnd":557.9000005722046,"responseStart":557.9000005722046,"secureConnectionStart":348.80000019073486},{"duration":275.5,"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":348.9000005722046,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":348.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":624.4000005722046,"responseStart":0,"secureConnectionStart":0},{"duration":209.4000005722046,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":349,"connectEnd":349,"connectStart":349,"domainLookupEnd":349,"domainLookupStart":349,"fetchStart":349,"redirectEnd":0,"redirectStart":0,"requestStart":349,"responseEnd":558.4000005722046,"responseStart":558.4000005722046,"secureConnectionStart":349},{"duration":275.4000005722046,"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":349.19999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":349.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":624.6000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":209.79999923706055,"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":349.4000005722046,"connectEnd":349.4000005722046,"connectStart":349.4000005722046,"domainLookupEnd":349.4000005722046,"domainLookupStart":349.4000005722046,"fetchStart":349.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":349.4000005722046,"responseEnd":559.1999998092651,"responseStart":559.1999998092651,"secureConnectionStart":349.4000005722046},{"duration":400,"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":350.30000019073486,"connectEnd":350.30000019073486,"connectStart":350.30000019073486,"domainLookupEnd":350.30000019073486,"domainLookupStart":350.30000019073486,"fetchStart":350.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":350.30000019073486,"responseEnd":750.3000001907349,"responseStart":750.3000001907349,"secureConnectionStart":350.30000019073486},{"duration":958.5999994277954,"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":350.4000005722046,"connectEnd":350.4000005722046,"connectStart":350.4000005722046,"domainLookupEnd":350.4000005722046,"domainLookupStart":350.4000005722046,"fetchStart":350.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":350.4000005722046,"responseEnd":1309,"responseStart":1309,"secureConnectionStart":350.4000005722046},{"duration":112.10000038146973,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":652,"connectEnd":652,"connectStart":652,"domainLookupEnd":652,"domainLookupStart":652,"fetchStart":652,"redirectEnd":0,"redirectStart":0,"requestStart":652,"responseEnd":764.1000003814697,"responseStart":764.1000003814697,"secureConnectionStart":652},{"duration":421,"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":903.6000003814697,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":903.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1324.6000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":420.6000003814697,"initiatorType":"link","name":"https://jira.mariadb.org/s/50bc9be5bfead1a25e72c1a9338c94f6-CDN/lu2cib/820016/12ta74/e108c7645258ccb43280ed3404e3e949/_/download/contextbatch/css/com.atlassian.jira.plugins.jira-development-integration-plugin:0,-_super,-jira.view.issue,-jira.global,-jira.general,-jira.browse.project,-project.issue.navigator,-atl.general/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":904.1999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":904.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1324.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":410.1000003814697,"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":905,"connectEnd":905,"connectStart":905,"domainLookupEnd":905,"domainLookupStart":905,"fetchStart":905,"redirectEnd":0,"redirectStart":0,"requestStart":905,"responseEnd":1315.1000003814697,"responseStart":1315.1000003814697,"secureConnectionStart":905},{"duration":418.8999996185303,"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":905.4000005722046,"connectEnd":905.4000005722046,"connectStart":905.4000005722046,"domainLookupEnd":905.4000005722046,"domainLookupStart":905.4000005722046,"fetchStart":905.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":905.4000005722046,"responseEnd":1324.3000001907349,"responseStart":1324.3000001907349,"secureConnectionStart":905.4000005722046},{"duration":419.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/e0bf5781d46ea69fb123572974cf39de-CDN/lu2cib/820016/12ta74/e108c7645258ccb43280ed3404e3e949/_/download/contextbatch/js/com.atlassian.jira.plugins.jira-development-integration-plugin:0,-_super,-jira.view.issue,-jira.global,-jira.general,-jira.browse.project,-project.issue.navigator,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":905.8000001907349,"connectEnd":905.8000001907349,"connectStart":905.8000001907349,"domainLookupEnd":905.8000001907349,"domainLookupStart":905.8000001907349,"fetchStart":905.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":905.8000001907349,"responseEnd":1325.6000003814697,"responseStart":1325.6000003814697,"secureConnectionStart":905.8000001907349},{"duration":464.3999996185303,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":945.9000005722046,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":945.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1410.3000001907349,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":183,"responseStart":340,"responseEnd":343,"domLoading":344,"domInteractive":1361,"domContentLoadedEventStart":1361,"domContentLoadedEventEnd":1410,"domComplete":1570,"loadEventStart":1570,"loadEventEnd":1571,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1335.6000003814697},{"name":"bigPipe.sidebar-id.end","time":1336.5},{"name":"bigPipe.activity-panel-pipe-id.start","time":1336.6999998092651},{"name":"bigPipe.activity-panel-pipe-id.end","time":1337.1999998092651},{"name":"activityTabFullyLoaded","time":1421.3000001907349}],"measures":[],"correlationId":"1f5d4d385002b2","effectiveType":"4g","downlink":9.8,"rtt":0,"serverDuration":89,"dbReadsTimeInMs":11,"dbConnsTimeInMs":19,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}