There is a big table in a statement-based parallel replication setup, like this:
CREATE TABLE `t` (
|
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
`action` enum('update','create','delete','query') NOT NULL,
|
`status` enum('unclaimed','claimed','error','completed','paused','cancelled','exemptable','violation','blocked') NOT NULL,
|
... more columns here ...
|
`last_change` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
`error_message` text CHARACTER SET utf8,
|
`partition_key` int(11) NOT NULL DEFAULT '0',
|
PRIMARY KEY (`id`),
|
... more multiple-column indexes here ...
|
) ENGINE=InnoDB AUTO_INCREMENT=3184963639 DEFAULT CHARSET=latin1
|
|
select * from information_schema.tables where TABLE_SCHEMA='test' and TABLE_NAME = 't'\G
|
*************************** 1. row ***************************
|
TABLE_CATALOG: def
|
TABLE_SCHEMA: test
|
TABLE_NAME: t
|
TABLE_TYPE: BASE TABLE
|
ENGINE: InnoDB
|
VERSION: 10
|
ROW_FORMAT: Compact
|
TABLE_ROWS: 271226130
|
AVG_ROW_LENGTH: 227
|
DATA_LENGTH: 61576822784
|
MAX_DATA_LENGTH: 0
|
INDEX_LENGTH: 93808164864
|
DATA_FREE: 27502051328
|
AUTO_INCREMENT: 3184963639
|
CREATE_TIME: 2016-08-05 13:08:55
|
UPDATE_TIME: NULL
|
CHECK_TIME: NULL
|
TABLE_COLLATION: latin1_swedish_ci
|
CHECKSUM: NULL
|
CREATE_OPTIONS:
|
TABLE_COMMENT:
|
1 row in set (0.00 sec)
|
Usually status is updated for several ids in a single UPDATE like this:
mysql> EXPLAIN UPDATE test.t SET status = 'claimed' WHERE id IN (3191531520, 3191531548, 3191675779, 3191675794, 3191849444, 3191879324, 3192120630, 3192120649, 3192120666, 3192120681, 3192120694, 3192120710, 3192120722, 3192120732, 3192120742, 3192120754, 3192120765, 3192152806, 3192177807, 3192252972, 3192284688, 3192284434, 3192284713, 3192284461, 3192284485, 3192284748, 3192284506, 3192284763, 3192284777, 3192284528, 3192284790, 3192284556, 3192284574, 3192284590, 3192284615, 3192284368, 3192284634, 3192284383, 3192284651, 3192284400, 3192284415, 3192284671, 3192440124, 3192570421, 3192570439, 3192570456, 3192570471, 3192570487)\G
|
*************************** 1. row ***************************
|
id: 1
|
select_type: SIMPLE
|
table: t
|
type: range
|
possible_keys: PRIMARY
|
key: PRIMARY
|
key_len: 8
|
ref: NULL
|
rows: 48
|
Extra: Using where
|
1 row in set (0.00 sec)
|
So, we have range access and reasonable estimation of rows in range. We may get this plan hundreds of times in a row, but sometimes we end up with a totally different plan while this same query is executed by slave:
2339259 system user test Connect 2594 updating UPDATE t SET status = 'claimed' WHERE id IN (3191531520, 3191531548, 3191675779, 3191675794, 3191849444, 3191879324, 3192120630, 3192120649, 3192120666, 3192120681, 3192120694, 3192120710, 3192120722, 3192120732, 3192120742, 3192120754, 3192120765, 3192152806, 3192177807, 3192252972, 3192284688, 3192284434, 3192284713, 3192284461, 3192284485, 3192284748, 3192284506, 3192284763, 3192284777, 3192284528, 3192284790, 3192284556, 3192284574, 3192284590, 3192284615, 3192284368, 3192284634, 3192284383, 3192284651, 3192284400, 3192284415, 3192284671, 3192440124, 3192570421, 3192570439, 3192570456, 3192570471, 3192570487) 0.000
|
|
mysql> SHOW EXPLAIN FOR 2339259\G
|
*************************** 1. row ***************************
|
id: 1
|
select_type: SIMPLE
|
table: t
|
type: index
|
possible_keys: PRIMARY
|
key: PRIMARY
|
key_len: 8
|
ref: NULL
|
rows: 1
|
Extra: Using where
|
1 row in set, 1 warning (0.01 sec)
|
Optimizer used full index scan for the PRIMARY key (and estimated rows as 1), and this caused a very slow execution of the query and millions of locks set in the process that stalled all other parallel replication threads eventually in a "deadlock".
I suspect there is a bug/corner case somewhere in the optimizer when it decides about indexes available for range access. Maybe this is caused by bad InnoDB statistics etc, but in any case I think we should prevent such an execution path.
- relates to
-
MDEV-10790
InnoDB statistics update may temporarily cause wrong index cardinalities
-
-
Open
- links to
-
{"report":{"fcp":1594.6999998092651,"ttfb":689.1999998092651,"pageVisibility":"visible","entityId":57763,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"9ec84f56-e57e-49a7-8cdb-c0dd3cfadcfb","navigationType":0,"readyForUser":1808.2999997138977,"redirectCount":0,"resourceLoadedEnd":2006.5999999046326,"resourceLoadedStart":695,"resourceTiming":[{"duration":149.59999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":695,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":695,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":844.5999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":156.80000019073486,"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":695.1999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":695.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":852,"responseStart":0,"secureConnectionStart":0},{"duration":227.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":695.3999996185303,"connectEnd":695.3999996185303,"connectStart":695.3999996185303,"domainLookupEnd":695.3999996185303,"domainLookupStart":695.3999996185303,"fetchStart":695.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":695.3999996185303,"responseEnd":922.8999996185303,"responseStart":922.8999996185303,"secureConnectionStart":695.3999996185303},{"duration":405.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":695.5999999046326,"connectEnd":695.5999999046326,"connectStart":695.5999999046326,"domainLookupEnd":695.5999999046326,"domainLookupStart":695.5999999046326,"fetchStart":695.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":695.5999999046326,"responseEnd":1101.0999999046326,"responseStart":1101.0999999046326,"secureConnectionStart":695.5999999046326},{"duration":409.59999990463257,"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":695.7999997138977,"connectEnd":695.7999997138977,"connectStart":695.7999997138977,"domainLookupEnd":695.7999997138977,"domainLookupStart":695.7999997138977,"fetchStart":695.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":695.7999997138977,"responseEnd":1105.3999996185303,"responseStart":1105.3999996185303,"secureConnectionStart":695.7999997138977},{"duration":410.09999990463257,"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":696.0999999046326,"connectEnd":696.0999999046326,"connectStart":696.0999999046326,"domainLookupEnd":696.0999999046326,"domainLookupStart":696.0999999046326,"fetchStart":696.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":696.0999999046326,"responseEnd":1106.1999998092651,"responseStart":1106.1999998092651,"secureConnectionStart":696.0999999046326},{"duration":410.80000019073486,"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":696.1999998092651,"connectEnd":696.1999998092651,"connectStart":696.1999998092651,"domainLookupEnd":696.1999998092651,"domainLookupStart":696.1999998092651,"fetchStart":696.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":696.1999998092651,"responseEnd":1107,"responseStart":1107,"secureConnectionStart":696.1999998092651},{"duration":411.6000003814697,"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":696.3999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":696.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1108,"responseStart":0,"secureConnectionStart":0},{"duration":411.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":696.5,"connectEnd":696.5,"connectStart":696.5,"domainLookupEnd":696.5,"domainLookupStart":696.5,"fetchStart":696.5,"redirectEnd":0,"redirectStart":0,"requestStart":696.5,"responseEnd":1108.0999999046326,"responseStart":1108.0999999046326,"secureConnectionStart":696.5},{"duration":412.59999990463257,"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":696.6999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":696.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1109.2999997138977,"responseStart":0,"secureConnectionStart":0},{"duration":412.30000019073486,"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":696.8999996185303,"connectEnd":696.8999996185303,"connectStart":696.8999996185303,"domainLookupEnd":696.8999996185303,"domainLookupStart":696.8999996185303,"fetchStart":696.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":696.8999996185303,"responseEnd":1109.1999998092651,"responseStart":1109.1999998092651,"secureConnectionStart":696.8999996185303},{"duration":871,"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":702.6999998092651,"connectEnd":702.6999998092651,"connectStart":702.6999998092651,"domainLookupEnd":702.6999998092651,"domainLookupStart":702.6999998092651,"fetchStart":702.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":702.6999998092651,"responseEnd":1573.6999998092651,"responseStart":1573.6999998092651,"secureConnectionStart":702.6999998092651},{"duration":1284,"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":702.7999997138977,"connectEnd":702.7999997138977,"connectStart":702.7999997138977,"domainLookupEnd":702.7999997138977,"domainLookupStart":702.7999997138977,"fetchStart":702.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":702.7999997138977,"responseEnd":1986.7999997138977,"responseStart":1986.7999997138977,"secureConnectionStart":702.7999997138977},{"duration":489.7000002861023,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1081.3999996185303,"connectEnd":1081.3999996185303,"connectStart":1081.3999996185303,"domainLookupEnd":1081.3999996185303,"domainLookupStart":1081.3999996185303,"fetchStart":1081.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":1081.3999996185303,"responseEnd":1571.0999999046326,"responseStart":1571.0999999046326,"secureConnectionStart":1081.3999996185303},{"duration":569.4000000953674,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1587.1999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1587.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2156.5999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":376.59999990463257,"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":1616.2999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1616.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1992.8999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":369.7000002861023,"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":1618.7999997138977,"connectEnd":1618.7999997138977,"connectStart":1618.7999997138977,"domainLookupEnd":1618.7999997138977,"domainLookupStart":1618.7999997138977,"fetchStart":1618.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":1618.7999997138977,"responseEnd":1988.5,"responseStart":1988.5,"secureConnectionStart":1618.7999997138977},{"duration":386.40000009536743,"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":1620.1999998092651,"connectEnd":1620.1999998092651,"connectStart":1620.1999998092651,"domainLookupEnd":1620.1999998092651,"domainLookupStart":1620.1999998092651,"fetchStart":1620.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":1620.1999998092651,"responseEnd":2006.5999999046326,"responseStart":2006.5999999046326,"secureConnectionStart":1620.1999998092651}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":513,"responseStart":689,"responseEnd":694,"domLoading":693,"domInteractive":2239,"domContentLoadedEventStart":2239,"domContentLoadedEventEnd":2316,"domComplete":2756,"loadEventStart":2756,"loadEventEnd":2756,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":2183.5},{"name":"bigPipe.sidebar-id.end","time":2184.5},{"name":"bigPipe.activity-panel-pipe-id.start","time":2184.5999999046326},{"name":"bigPipe.activity-panel-pipe-id.end","time":2186.199999809265},{"name":"activityTabFullyLoaded","time":2339.5999999046326}],"measures":[],"correlationId":"ef2e91d1a868e8","effectiveType":"4g","downlink":9.3,"rtt":0,"serverDuration":109,"dbReadsTimeInMs":13,"dbConnsTimeInMs":22,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Attached files
10.0-debug-printouts.diff includes
mdev10649.test