Type:
Bug
Priority:
Critical
Resolution:
Fixed
Affects Version/s:
10.5
When a client runs an insert / delete / update on a master in a XA transaction, the replication fails if the following conditions are true:
`replicate_do_db` is present on the slave
A schema outside of `replicate_do_db` is touched either because:
DML statements are executed with a schema selected that is not listed in `replicate_do_db`
including none (e.g. no `USE` or `USE junkschema` vs `USE srcschema`)
DML statements are executed on a schema outside of those listed in `replicate_do_db`
Two phase commits are used
Considering the following setup in 10.5:
Master:
[mariadb]
log-bin
server_id=1
log-basename=master-mariadb
CREATE SCHEMA srcschema;
USE srcschema;
CREATE TABLE `srctable`
(
`srcidentity` int (11) NOT NULL ,
`srcnumber` int (11) NOT NULL ,
PRIMARY KEY (`srcidentity`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8
COLLATE = utf8_general_ci;
CREATE SCHEMA junkschema;
USE junkschema;
CREATE TABLE `junktable`
(
`srcidentity` int (11) NOT NULL ,
`srcnumber` int (11) NOT NULL ,
PRIMARY KEY (`srcidentity`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8
COLLATE = utf8_general_ci
Slave:
[mariadb]
server_id=2
log-basename=slave-mariadb
replicate_do_db=srcschema
replicate_wild_do_table=srcschema.%
This will crash the replication:
USE outside replicate_do_db
XA START 'testtx1' ;
USE junkschema;
INSERT INTO srcschema.srctable (srcidentity,srcnumber) VALUES (2,2);
XA END 'testtx1' ;
XA PREPARE 'testtx1' ;
XA COMMIT 'testtx1' ;
No USE
XA START 'testtx1' ;
INSERT INTO srcschema.srctable (srcidentity,srcnumber) VALUES (1,1);
XA END 'testtx1' ;
XA PREPARE 'testtx1' ;
XA COMMIT 'testtx1' ;
DML outside replicate_do_db
XA START 'testtx1' ;
USE junkschema;
INSERT INTO junkschema.junktable (srcidentity,srcnumber) VALUES (1,1);
XA END 'testtx1' ;
XA PREPARE 'testtx1' ;
XA COMMIT 'testtx1' ;
For control this will pass:
XA START 'testtx1' ;
USE srcschema;
INSERT INTO srcschema.srctable (srcidentity,srcnumber) VALUES (1,1);
XA END 'testtx1' ;
XA PREPARE 'testtx1' ;
XA COMMIT 'testtx1' ;
You can find my replication setup using Docker here: https://github.com/WorksWithJava/Mariadb-XA-10.5-bug-replication
MariaDB logs:
database_bugged_slave_setup-slave-1 | 2024-04-17 5:33:44 4 [Note] Slave I/O thread: connected to master 'slave_user@mariadb-master:3306',replication started in log 'FIRST' at position 4
database_bugged_slave_setup-master-1 | 2024-04-17 5:33:44 4 [Note] Start binlog_dump to slave_server(2), pos(, 4), using_gtid(0), gtid('')
database_bugged_slave_setup-slave-1 | 2024-04-17 5:33:46 5 [ERROR] Slave SQL: XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state, Gtid 0-1-7, Internal MariaDB error code: 1399
database_bugged_slave_setup-slave-1 | 2024-04-17 5:33:46 5 [Warning] Slave: XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state Error_code: 1399
database_bugged_slave_setup-slave-1 | 2024-04-17 5:33:46 5 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'master-mariadb-bin.000002' position 351
database_bugged_slave_setup-slave-1 | 2024-04-17 5:33:46 5 [Note] Slave SQL thread exiting, replication stopped in log 'master-mariadb-bin.000002' at position 351
database_bugged_slave_setup-slave-1 | 2024-04-17 5:33:46 5 [Note] master was mariadb-master:3306
{"report":{"fcp":987.6000000238419,"ttfb":212,"pageVisibility":"visible","entityId":128760,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"178c3d16-5fb3-4d79-a6a9-2f6b6b203ab2","navigationType":0,"readyForUser":1086.300000011921,"redirectCount":0,"resourceLoadedEnd":677,"resourceLoadedStart":218.4000000357628,"resourceTiming":[{"duration":297.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":218.4000000357628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":218.4000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":515.9000000357628,"responseStart":0,"secureConnectionStart":0},{"duration":297.5999999642372,"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":218.60000002384186,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":218.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":516.1999999880791,"responseStart":0,"secureConnectionStart":0},{"duration":308.5999999642372,"initiatorType":"script","name":"https://jira.mariadb.org/s/e9b27a47da5fb0f74a35acd57e9847fb-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":218.9000000357628,"connectEnd":218.9000000357628,"connectStart":218.9000000357628,"domainLookupEnd":218.9000000357628,"domainLookupStart":218.9000000357628,"fetchStart":218.9000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":218.9000000357628,"responseEnd":527.5,"responseStart":527.5,"secureConnectionStart":218.9000000357628},{"duration":352.5,"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":219.10000002384186,"connectEnd":219.10000002384186,"connectStart":219.10000002384186,"domainLookupEnd":219.10000002384186,"domainLookupStart":219.10000002384186,"fetchStart":219.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":219.10000002384186,"responseEnd":571.6000000238419,"responseStart":571.6000000238419,"secureConnectionStart":219.10000002384186},{"duration":356.10000002384186,"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":219.30000001192093,"connectEnd":219.30000001192093,"connectStart":219.30000001192093,"domainLookupEnd":219.30000001192093,"domainLookupStart":219.30000001192093,"fetchStart":219.30000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":219.30000001192093,"responseEnd":575.4000000357628,"responseStart":575.4000000357628,"secureConnectionStart":219.30000001192093},{"duration":356.4000000357628,"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":219.5,"connectEnd":219.5,"connectStart":219.5,"domainLookupEnd":219.5,"domainLookupStart":219.5,"fetchStart":219.5,"redirectEnd":0,"redirectStart":0,"requestStart":219.5,"responseEnd":575.9000000357628,"responseStart":575.9000000357628,"secureConnectionStart":219.5},{"duration":356.5,"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":219.69999998807907,"connectEnd":219.69999998807907,"connectStart":219.69999998807907,"domainLookupEnd":219.69999998807907,"domainLookupStart":219.69999998807907,"fetchStart":219.69999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":219.69999998807907,"responseEnd":576.1999999880791,"responseStart":576.1999999880791,"secureConnectionStart":219.69999998807907},{"duration":449.19999998807907,"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":219.80000001192093,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":219.80000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":669,"responseStart":0,"secureConnectionStart":0},{"duration":356.60000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":220,"connectEnd":220,"connectStart":220,"domainLookupEnd":220,"domainLookupStart":220,"fetchStart":220,"redirectEnd":0,"redirectStart":0,"requestStart":220,"responseEnd":576.6000000238419,"responseStart":576.6000000238419,"secureConnectionStart":220},{"duration":448.80000001192093,"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":220.30000001192093,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":220.30000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":669.1000000238419,"responseStart":0,"secureConnectionStart":0},{"duration":356.7999999523163,"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":220.4000000357628,"connectEnd":220.4000000357628,"connectStart":220.4000000357628,"domainLookupEnd":220.4000000357628,"domainLookupStart":220.4000000357628,"fetchStart":220.4000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":220.4000000357628,"responseEnd":577.1999999880791,"responseStart":577.1999999880791,"secureConnectionStart":220.4000000357628},{"duration":449.89999997615814,"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":225.80000001192093,"connectEnd":225.80000001192093,"connectStart":225.80000001192093,"domainLookupEnd":225.80000001192093,"domainLookupStart":225.80000001192093,"fetchStart":225.80000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":225.80000001192093,"responseEnd":675.6999999880791,"responseStart":675.6999999880791,"secureConnectionStart":225.80000001192093},{"duration":451.0999999642372,"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":225.9000000357628,"connectEnd":225.9000000357628,"connectStart":225.9000000357628,"domainLookupEnd":225.9000000357628,"domainLookupStart":225.9000000357628,"fetchStart":225.9000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":225.9000000357628,"responseEnd":677,"responseStart":677,"secureConnectionStart":225.9000000357628},{"duration":79.30000001192093,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":697.3000000119209,"connectEnd":697.3000000119209,"connectStart":697.3000000119209,"domainLookupEnd":697.3000000119209,"domainLookupStart":697.3000000119209,"fetchStart":697.3000000119209,"redirectEnd":0,"redirectStart":0,"requestStart":697.3000000119209,"responseEnd":776.6000000238419,"responseStart":776.6000000238419,"secureConnectionStart":697.3000000119209}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":17,"responseStart":212,"responseEnd":216,"domLoading":215,"domInteractive":1192,"domContentLoadedEventStart":1192,"domContentLoadedEventEnd":1249,"domComplete":2110,"loadEventStart":2110,"loadEventEnd":2112,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1172.1000000238419},{"name":"bigPipe.sidebar-id.end","time":1172.9000000357628},{"name":"bigPipe.activity-panel-pipe-id.start","time":1173},{"name":"bigPipe.activity-panel-pipe-id.end","time":1175.6000000238419},{"name":"activityTabFullyLoaded","time":1258}],"measures":[],"correlationId":"496666f86c7dad","effectiveType":"4g","downlink":9.1,"rtt":0,"serverDuration":113,"dbReadsTimeInMs":19,"dbConnsTimeInMs":28,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}