Tested on: 10.6.19-15 Enterprise (consistent), 10.6.19 Community (consistent), 11.4.5 Community (consistent)
- You will need 3 instances to make this occur: Master (db1) / Slave (db2) / Slave (db3)
- The backup is taken on the SLAVE that is running, but after restore on the other slave, replication is connected to master.
- If inserts on the master are slowed down to one per second, this failure does not occur and checksum table shows that tables are perfect copies.
- If the table is ENGINE=INNODB the failure will not occur.
On master, create a table:
Drop schema if exists Rpa; Create schema Rpa; Use Rpa;
|
DROP TABLE IF EXISTS `aria_table`;
|
CREATE TABLE `aria_table` (
|
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
`message` longtext NOT NULL, `createdOn` datetime NOT NULL DEFAULT current_timestamp(),
|
`processId` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `idx_svax` (`processId`)
|
) ENGINE=ARIA AUTO_INCREMENT=7295 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci PAGE_CHECKSUM=1;
|
On master, run a bash script that quickly inserts into the aria_table:
#!/bin/bash
|
touch t.txt
|
mariadb -Ae "truncate table Rpa.aria_table;"
|
ii=0
|
while [ -f t.txt ]; do
|
ii=$(( $ii + 1 ))
|
mariadb -Ae "use Rpa; INSERT INTO aria_table ( message, createdOn, processId) VALUES ( 'Lorem ipsum dolor sit amet, et pharetra nulla tincidunt.', now(), round(rand()*10000000));"
|
echo $ii
|
done
|
echo "finished"
|
Verify that db2 is a slave of db1 and that the slave is running.
On db3, stop server, destroy the data:
systemctl stop mariadb
|
datadir=/var/lib/mysql
|
logdir=/var/log/mysql
|
rm -fr $datadir/* $logdir/*
|
On db2, use mariabackup to stream a backup into the datadir of db3:
datadir=/var/lib/mysql
|
replica=192.168.8.113
|
mariabackup --user=root --backup --stream=xbstream | ssh -o StrictHostKeyChecking=NO root@"$replica" -t "cd $datadir; mbstream -x"
|
On db3, set the replication to db1
mhost=db1.edw.ee
|
datadir=/var/lib/mysql
|
logdir=/var/log/mysql
|
mport=3306
|
mpw=password
|
muser=repl
|
|
# Test the connectivity from this replica node to the primary:
|
mariadb -h$mhost -u$muser -p$mpw -ABNe "select now(); select @@hostname;"
|
|
cd $datadir
|
|
gtid=$(cat $datadir/*_binlog_info | tail -1 | awk '{print $3}')
|
echo $gtid $mhost $mport $muser $mpw
|
|
mariabackup --prepare --target-dir=$datadir
|
|
chown -R mysql:mysql $datadir
|
chown -R mysql:mysql $logdir
|
|
systemctl start mariadb;
|
|
mariadb -ABNe "stop slave; reset slave; set global gtid_slave_pos='$gtid'; change master to master_host='$mhost', master_port=$mport, master_user='$muser', master_password='$mpw', master_use_gtid=slave_pos; start slave;"
|
|
mariadb -Ae "show replica status\G"
|
ERROR OCCURS!
Last_SQL_Error: Error 'Duplicate entry '9699' for key 'PRIMARY'' on query. Default database: 'Rpa'. Query: 'INSERT INTO aria_table ( message, createdOn, processId) VALUES ( 'Lorem ipsum dolor sit amet, et pharetra nulla tincidunt.', now(), round(rand()*10000000))'
|
{"report":{"fcp":843.3000000715256,"ttfb":281.10000002384186,"pageVisibility":"visible","entityId":132948,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"13a31979-a782-4129-bb32-a6711e26d43f","navigationType":0,"readyForUser":920.9000000953674,"redirectCount":0,"resourceLoadedEnd":931.5,"resourceLoadedStart":290,"resourceTiming":[{"duration":87.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":290,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":290,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":377.5,"responseStart":0,"secureConnectionStart":0},{"duration":87.60000002384186,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/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":290.2000000476837,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":290.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":377.8000000715256,"responseStart":0,"secureConnectionStart":0},{"duration":103.69999992847443,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":290.40000009536743,"connectEnd":290.40000009536743,"connectStart":290.40000009536743,"domainLookupEnd":290.40000009536743,"domainLookupStart":290.40000009536743,"fetchStart":290.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":290.40000009536743,"responseEnd":394.10000002384186,"responseStart":394.10000002384186,"secureConnectionStart":290.40000009536743},{"duration":184.10000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/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":290.5,"connectEnd":290.5,"connectStart":290.5,"domainLookupEnd":290.5,"domainLookupStart":290.5,"fetchStart":290.5,"redirectEnd":0,"redirectStart":0,"requestStart":290.5,"responseEnd":474.60000002384186,"responseStart":474.60000002384186,"secureConnectionStart":290.5},{"duration":187.60000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":290.8000000715256,"connectEnd":290.8000000715256,"connectStart":290.8000000715256,"domainLookupEnd":290.8000000715256,"domainLookupStart":290.8000000715256,"fetchStart":290.8000000715256,"redirectEnd":0,"redirectStart":0,"requestStart":290.8000000715256,"responseEnd":478.40000009536743,"responseStart":478.40000009536743,"secureConnectionStart":290.8000000715256},{"duration":187.89999997615814,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":290.90000009536743,"connectEnd":290.90000009536743,"connectStart":290.90000009536743,"domainLookupEnd":290.90000009536743,"domainLookupStart":290.90000009536743,"fetchStart":290.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":290.90000009536743,"responseEnd":478.8000000715256,"responseStart":478.8000000715256,"secureConnectionStart":290.90000009536743},{"duration":188,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":291.10000002384186,"connectEnd":291.10000002384186,"connectStart":291.10000002384186,"domainLookupEnd":291.10000002384186,"domainLookupStart":291.10000002384186,"fetchStart":291.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":291.10000002384186,"responseEnd":479.10000002384186,"responseStart":479.10000002384186,"secureConnectionStart":291.10000002384186},{"duration":244.39999997615814,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":291.3000000715256,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":291.3000000715256,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":535.7000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":188.10000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":291.5,"connectEnd":291.5,"connectStart":291.5,"domainLookupEnd":291.5,"domainLookupStart":291.5,"fetchStart":291.5,"redirectEnd":0,"redirectStart":0,"requestStart":291.5,"responseEnd":479.60000002384186,"responseStart":479.60000002384186,"secureConnectionStart":291.5},{"duration":244.30000007152557,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/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":291.60000002384186,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":291.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":535.9000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":188.60000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/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":291.7000000476837,"connectEnd":291.7000000476837,"connectStart":291.7000000476837,"domainLookupEnd":291.7000000476837,"domainLookupStart":291.7000000476837,"fetchStart":291.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":291.7000000476837,"responseEnd":480.3000000715256,"responseStart":480.3000000715256,"secureConnectionStart":291.7000000476837},{"duration":638.2000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":292.5,"connectEnd":292.5,"connectStart":292.5,"domainLookupEnd":292.5,"domainLookupStart":292.5,"fetchStart":292.5,"redirectEnd":0,"redirectStart":0,"requestStart":292.5,"responseEnd":930.7000000476837,"responseStart":930.7000000476837,"secureConnectionStart":292.5},{"duration":634.3999999761581,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":297.10000002384186,"connectEnd":297.10000002384186,"connectStart":297.10000002384186,"domainLookupEnd":297.10000002384186,"domainLookupStart":297.10000002384186,"fetchStart":297.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":297.10000002384186,"responseEnd":931.5,"responseStart":931.5,"secureConnectionStart":297.10000002384186},{"duration":310.8000000715256,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":547.1000000238419,"connectEnd":547.1000000238419,"connectStart":547.1000000238419,"domainLookupEnd":547.1000000238419,"domainLookupStart":547.1000000238419,"fetchStart":547.1000000238419,"redirectEnd":0,"redirectStart":0,"requestStart":547.1000000238419,"responseEnd":857.9000000953674,"responseStart":857.9000000953674,"secureConnectionStart":547.1000000238419},{"duration":214.5,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":836.4000000953674,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":836.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1050.9000000953674,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":98,"responseStart":281,"responseEnd":293,"domLoading":287,"domInteractive":1058,"domContentLoadedEventStart":1058,"domContentLoadedEventEnd":1107,"domComplete":1376,"loadEventStart":1376,"loadEventEnd":1376,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1019.9000000953674},{"name":"bigPipe.sidebar-id.end","time":1020.6000000238419},{"name":"bigPipe.activity-panel-pipe-id.start","time":1020.7000000476837},{"name":"bigPipe.activity-panel-pipe-id.end","time":1025.3000000715256},{"name":"activityTabFullyLoaded","time":1124.9000000953674}],"measures":[],"correlationId":"63a9072857c0ba","effectiveType":"4g","downlink":9.3,"rtt":0,"serverDuration":111,"dbReadsTimeInMs":13,"dbConnsTimeInMs":22,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
So, the problem is with mariabackup --stream=xbstream only. Normal backup works fine.