there are, perhaps, may ways that gap locks can be places differently on the master and on the slave. combined with 10.5+ XA binlogging (MDEV-742) this can cause locks to timeout on slaves. breaking replication. For example:
# this test case can be run with read-committed (or higher) isolation leven
|
source include/have_innodb.inc;
|
source include/have_binlog_format_row.inc;
|
source include/master-slave.inc;
|
create table t1 (a int primary key, b int unique) engine=innodb;
|
insert t1 values (1,1),(3,3),(5,5);
|
sync_slave_with_master;
|
|
# set a strong isolation level to keep the read view below.
|
# alternatively a long-running select can do that too even in read-committed
|
set session tx_isolation='repeatable-read';
|
start transaction;
|
# opens a read view to disable purge on the slave
|
select * from t1;
|
|
connect m2, localhost, root;
|
# now, delete a value, purge it on the master, but not on the slave
|
delete from t1 where a=3;
|
xa start 'x1';
|
# this sets a gap lock on <3>, when it exists (so, on the slave)
|
update t1 set b=3 where a=5;
|
xa end 'x1';
|
xa prepare 'x1';
|
|
connect m3, localhost, root;
|
# and this tries to insert straight into the locked gap
|
insert t1 values (2, 2);
|
|
echo -->slave;
|
sync_slave_with_master;
|
commit;
|
select * from t1;
|
|
connection m2;
|
xa rollback 'x1';
|
drop table t1;
|
source include/rpl_end.inc;
|
A possible way to fix all lock timeouts on the slave caused by gap locks and XA is to release gap locks on XA prepare.
{"report":{"fcp":917.5,"ttfb":227.5999994277954,"pageVisibility":"visible","entityId":103220,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"2704bbd2-d0b4-454e-b2b3-3f30e7cafca8","navigationType":0,"readyForUser":1019.8999996185303,"redirectCount":0,"resourceLoadedEnd":917.5,"resourceLoadedStart":233.5999994277954,"resourceTiming":[{"duration":148.60000038146973,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":233.5999994277954,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":233.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":382.19999980926514,"responseStart":0,"secureConnectionStart":0},{"duration":148.60000038146973,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/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":233.89999961853027,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":233.89999961853027,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":382.5,"responseStart":0,"secureConnectionStart":0},{"duration":165.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":234,"connectEnd":234,"connectStart":234,"domainLookupEnd":234,"domainLookupStart":234,"fetchStart":234,"redirectEnd":0,"redirectStart":0,"requestStart":234,"responseEnd":399.5,"responseStart":399.5,"secureConnectionStart":234},{"duration":250.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/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":234.19999980926514,"connectEnd":234.19999980926514,"connectStart":234.19999980926514,"domainLookupEnd":234.19999980926514,"domainLookupStart":234.19999980926514,"fetchStart":234.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":234.19999980926514,"responseEnd":485,"responseStart":485,"secureConnectionStart":234.19999980926514},{"duration":254.4000005722046,"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":234.39999961853027,"connectEnd":234.39999961853027,"connectStart":234.39999961853027,"domainLookupEnd":234.39999961853027,"domainLookupStart":234.39999961853027,"fetchStart":234.39999961853027,"redirectEnd":0,"redirectStart":0,"requestStart":234.39999961853027,"responseEnd":488.80000019073486,"responseStart":488.80000019073486,"secureConnectionStart":234.39999961853027},{"duration":254.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":234.69999980926514,"connectEnd":234.69999980926514,"connectStart":234.69999980926514,"domainLookupEnd":234.69999980926514,"domainLookupStart":234.69999980926514,"fetchStart":234.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":234.69999980926514,"responseEnd":489.19999980926514,"responseStart":489.19999980926514,"secureConnectionStart":234.69999980926514},{"duration":254.69999980926514,"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":234.89999961853027,"connectEnd":234.89999961853027,"connectStart":234.89999961853027,"domainLookupEnd":234.89999961853027,"domainLookupStart":234.89999961853027,"fetchStart":234.89999961853027,"redirectEnd":0,"redirectStart":0,"requestStart":234.89999961853027,"responseEnd":489.5999994277954,"responseStart":489.5999994277954,"secureConnectionStart":234.89999961853027},{"duration":308.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":235.0999994277954,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":235.0999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":543.6999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":254.89999961853027,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":235.19999980926514,"connectEnd":235.19999980926514,"connectStart":235.19999980926514,"domainLookupEnd":235.19999980926514,"domainLookupStart":235.19999980926514,"fetchStart":235.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":235.19999980926514,"responseEnd":490.0999994277954,"responseStart":490.0999994277954,"secureConnectionStart":235.19999980926514},{"duration":308.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":235.39999961853027,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":235.39999961853027,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":543.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":255,"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":235.5999994277954,"connectEnd":235.5999994277954,"connectStart":235.5999994277954,"domainLookupEnd":235.5999994277954,"domainLookupStart":235.5999994277954,"fetchStart":235.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":235.5999994277954,"responseEnd":490.5999994277954,"responseStart":490.5999994277954,"secureConnectionStart":235.5999994277954},{"duration":445.80000019073486,"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":237.0999994277954,"connectEnd":237.0999994277954,"connectStart":237.0999994277954,"domainLookupEnd":237.0999994277954,"domainLookupStart":237.0999994277954,"fetchStart":237.0999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":237.0999994277954,"responseEnd":682.8999996185303,"responseStart":682.8999996185303,"secureConnectionStart":237.0999994277954},{"duration":680.3000001907349,"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":237.19999980926514,"connectEnd":237.19999980926514,"connectStart":237.19999980926514,"domainLookupEnd":237.19999980926514,"domainLookupStart":237.19999980926514,"fetchStart":237.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":237.19999980926514,"responseEnd":917.5,"responseStart":917.5,"secureConnectionStart":237.19999980926514},{"duration":127,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":556.1999998092651,"connectEnd":556.1999998092651,"connectStart":556.1999998092651,"domainLookupEnd":556.1999998092651,"domainLookupStart":556.1999998092651,"fetchStart":556.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":556.1999998092651,"responseEnd":683.1999998092651,"responseStart":683.1999998092651,"secureConnectionStart":556.1999998092651},{"duration":277.8999996185303,"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","startTime":815.5,"connectEnd":815.5,"connectStart":815.5,"domainLookupEnd":815.5,"domainLookupStart":815.5,"fetchStart":815.5,"redirectEnd":0,"redirectStart":0,"requestStart":815.5,"responseEnd":1093.3999996185303,"responseStart":1093.3999996185303,"secureConnectionStart":815.5}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":45,"responseStart":228,"responseEnd":232,"domLoading":231,"domInteractive":1087,"domContentLoadedEventStart":1087,"domContentLoadedEventEnd":1133,"domComplete":1886,"loadEventStart":1886,"loadEventEnd":1888,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1072.5},{"name":"bigPipe.sidebar-id.end","time":1073.3999996185303},{"name":"bigPipe.activity-panel-pipe-id.start","time":1073.3999996185303},{"name":"bigPipe.activity-panel-pipe-id.end","time":1077.8000001907349},{"name":"activityTabFullyLoaded","time":1153.6999998092651}],"measures":[],"correlationId":"f69a26421e2b42","effectiveType":"4g","downlink":9.6,"rtt":0,"serverDuration":109,"dbReadsTimeInMs":23,"dbConnsTimeInMs":31,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}