When master crashes in the middle of writing a multi-statement transaction to binlog so that slave has already received some events from this transaction, then IO thread reconnects to the restarted master and thinks that it will re-download the same binlog events. But master will actually either not send anything (if no new transactions has executed), or will send completely different events from new transactions which will result in completely different data on the slave compared to data on the master.
I'd bet the root cause of the problem is in how IO thread reconnects when GTID-based replication is turned on, and in these few lines of code starting at sql/slave.cc:5310:
/*
|
Do not queue any format description event that we receive after a
|
reconnect where we are skipping over a partial event group received
|
before the reconnect.
|
|
(If we queued such an event, and it was the first format_description
|
event after master restart, the slave SQL thread would think that
|
the partial event group before it in the relay log was from a
|
previous master crash and should be rolled back).
|
*/
|
if (unlikely(mi->gtid_reconnect_event_skip_count && !mi->gtid_event_seen))
|
gtid_skip_enqueue= true;
|
In the scenario I described above SQL thread actually must roll back the active transaction.
In the attachment is the patch that allows to emulate this scenario. Apply it, run rpl_gtid_crash test and look at the results of last two SELECTs – they will be different on master and slave.
I will look into a way to fix this problem myself, but will appreciate any help. I'll attach a patch if I manage to find a fix before anyone on MariaDB side.
{"report":{"fcp":851.1999998092651,"ttfb":201.80000019073486,"pageVisibility":"visible","entityId":41020,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"b5649069-e154-42c3-b042-e0455f2dc9da","navigationType":0,"readyForUser":989.8999996185303,"redirectCount":0,"resourceLoadedEnd":1017.1999998092651,"resourceLoadedStart":207.5,"resourceTiming":[{"duration":176.60000038146973,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":207.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":207.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":384.1000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":176.69999980926514,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/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":207.69999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":207.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":384.3999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":185.70000076293945,"initiatorType":"script","name":"https://jira.mariadb.org/s/e9b27a47da5fb0f74a35acd57e9847fb-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":207.89999961853027,"connectEnd":207.89999961853027,"connectStart":207.89999961853027,"domainLookupEnd":207.89999961853027,"domainLookupStart":207.89999961853027,"fetchStart":207.89999961853027,"redirectEnd":0,"redirectStart":0,"requestStart":207.89999961853027,"responseEnd":393.6000003814697,"responseStart":393.6000003814697,"secureConnectionStart":207.89999961853027},{"duration":271.0999994277954,"initiatorType":"script","name":"https://jira.mariadb.org/s/c32eb0da7ad9831253f8397e6cc26afd-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/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":208.10000038146973,"connectEnd":208.10000038146973,"connectStart":208.10000038146973,"domainLookupEnd":208.10000038146973,"domainLookupStart":208.10000038146973,"fetchStart":208.10000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":208.10000038146973,"responseEnd":479.19999980926514,"responseStart":479.19999980926514,"secureConnectionStart":208.10000038146973},{"duration":274.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/bc0bcb146314416123c992714ee00ff7-CDN/lu2bv2/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":208.30000019073486,"connectEnd":208.30000019073486,"connectStart":208.30000019073486,"domainLookupEnd":208.30000019073486,"domainLookupStart":208.30000019073486,"fetchStart":208.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":208.30000019073486,"responseEnd":483,"responseStart":483,"secureConnectionStart":208.30000019073486},{"duration":275,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":208.5,"connectEnd":208.5,"connectStart":208.5,"domainLookupEnd":208.5,"domainLookupStart":208.5,"fetchStart":208.5,"redirectEnd":0,"redirectStart":0,"requestStart":208.5,"responseEnd":483.5,"responseStart":483.5,"secureConnectionStart":208.5},{"duration":275.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":208.69999980926514,"connectEnd":208.69999980926514,"connectStart":208.69999980926514,"domainLookupEnd":208.69999980926514,"domainLookupStart":208.69999980926514,"fetchStart":208.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":208.69999980926514,"responseEnd":484,"responseStart":484,"secureConnectionStart":208.69999980926514},{"duration":329.80000019073486,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bv2/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":208.80000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":208.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":538.6000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":275.5,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":208.89999961853027,"connectEnd":208.89999961853027,"connectStart":208.89999961853027,"domainLookupEnd":208.89999961853027,"domainLookupStart":208.89999961853027,"fetchStart":208.89999961853027,"redirectEnd":0,"redirectStart":0,"requestStart":208.89999961853027,"responseEnd":484.3999996185303,"responseStart":484.3999996185303,"secureConnectionStart":208.89999961853027},{"duration":329.5999994277954,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bv2/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":209.10000038146973,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":209.10000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":538.6999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":275.8999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/s/719848dd97ebe0663199f49a3936487a-CDN/lu2bv2/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":209.30000019073486,"connectEnd":209.30000019073486,"connectStart":209.30000019073486,"domainLookupEnd":209.30000019073486,"domainLookupStart":209.30000019073486,"fetchStart":209.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":209.30000019073486,"responseEnd":485.19999980926514,"responseStart":485.19999980926514,"secureConnectionStart":209.30000019073486},{"duration":608.4000005722046,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":210.19999980926514,"connectEnd":210.19999980926514,"connectStart":210.19999980926514,"domainLookupEnd":210.19999980926514,"domainLookupStart":210.19999980926514,"fetchStart":210.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":210.19999980926514,"responseEnd":818.6000003814697,"responseStart":818.6000003814697,"secureConnectionStart":210.19999980926514},{"duration":622.6000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":210.19999980926514,"connectEnd":210.19999980926514,"connectStart":210.19999980926514,"domainLookupEnd":210.19999980926514,"domainLookupStart":210.19999980926514,"fetchStart":210.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":210.19999980926514,"responseEnd":832.8000001907349,"responseStart":832.8000001907349,"secureConnectionStart":210.19999980926514},{"duration":268.80000019073486,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":550.5,"connectEnd":550.5,"connectStart":550.5,"domainLookupEnd":550.5,"domainLookupStart":550.5,"fetchStart":550.5,"redirectEnd":0,"redirectStart":0,"requestStart":550.5,"responseEnd":819.3000001907349,"responseStart":819.3000001907349,"secureConnectionStart":550.5},{"duration":179.0999994277954,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":844.3000001907349,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":844.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1023.3999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":149.30000019073486,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2bv2/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","startTime":867.6999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":867.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1017,"responseStart":0,"secureConnectionStart":0},{"duration":148.89999961853027,"initiatorType":"link","name":"https://jira.mariadb.org/s/50bc9be5bfead1a25e72c1a9338c94f6-CDN/lu2bv2/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","startTime":868.3000001907349,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":868.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1017.1999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":110.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/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":869.1000003814697,"connectEnd":869.1000003814697,"connectStart":869.1000003814697,"domainLookupEnd":869.1000003814697,"domainLookupStart":869.1000003814697,"fetchStart":869.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":869.1000003814697,"responseEnd":979.8000001907349,"responseStart":979.8000001907349,"secureConnectionStart":869.1000003814697},{"duration":131.0999994277954,"initiatorType":"script","name":"https://jira.mariadb.org/s/53a43b6764f587426c7bb9a150184c00-CDN/lu2bv2/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","startTime":869.6000003814697,"connectEnd":869.6000003814697,"connectStart":869.6000003814697,"domainLookupEnd":869.6000003814697,"domainLookupStart":869.6000003814697,"fetchStart":869.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":869.6000003814697,"responseEnd":1000.6999998092651,"responseStart":1000.6999998092651,"secureConnectionStart":869.6000003814697},{"duration":132.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/630dda803a823fdd5771c4338338e018-CDN/lu2bv2/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","startTime":870.1999998092651,"connectEnd":870.1999998092651,"connectStart":870.1999998092651,"domainLookupEnd":870.1999998092651,"domainLookupStart":870.1999998092651,"fetchStart":870.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":870.1999998092651,"responseEnd":1002.3999996185303,"responseStart":1002.3999996185303,"secureConnectionStart":870.1999998092651}],"fetchStart":1,"domainLookupStart":1,"domainLookupEnd":1,"connectStart":1,"connectEnd":1,"requestStart":49,"responseStart":202,"responseEnd":205,"domLoading":206,"domInteractive":1064,"domContentLoadedEventStart":1065,"domContentLoadedEventEnd":1108,"domComplete":1769,"loadEventStart":1769,"loadEventEnd":1771,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1027.1999998092651},{"name":"bigPipe.sidebar-id.end","time":1028},{"name":"bigPipe.activity-panel-pipe-id.start","time":1028.1000003814697},{"name":"bigPipe.activity-panel-pipe-id.end","time":1030.6000003814697},{"name":"activityTabFullyLoaded","time":1117.6999998092651}],"measures":[],"correlationId":"76188be20c4529","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":93,"dbReadsTimeInMs":10,"dbConnsTimeInMs":18,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}