Skip to content

Commit edda2fd

Browse files
committed
MDEV-20703: mariabackup creates binlog files in server binlog directory on --prepare --export step
When "--export" mariabackup option is used, mariabackup starts the server in bootstrap mode to generate *.cfg files for the certain innodb tables. The started instance of the server reads options from the file, pointed out in "--defaults-file" mariabackup option. If the server uses the same config file as mariabackup, and binlog is switched on in that config file, then "mariabackup --prepare --export" will create binary log files in the server's binary log directory, what can cause issues. The fix is to add "--skip-log-bin" in mysld options when the server is started to generate *.cfg files.
1 parent f203245 commit edda2fd

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

extra/mariabackup/xtrabackup.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,8 @@ static int prepare_export()
15351535
" --defaults-extra-file=./backup-my.cnf --defaults-group-suffix=%s --datadir=."
15361536
" --innodb --innodb-fast-shutdown=0 --loose-partition"
15371537
" --innodb_purge_rseg_truncate_frequency=1 --innodb-buffer-pool-size=%llu"
1538-
" --console --skip-log-error --bootstrap < " BOOTSTRAP_FILENAME IF_WIN("\"",""),
1538+
" --console --skip-log-error --skip-log-bin --bootstrap < "
1539+
BOOTSTRAP_FILENAME IF_WIN("\"",""),
15391540
mariabackup_exe,
15401541
orig_argv1, (my_defaults_group_suffix?my_defaults_group_suffix:""),
15411542
xtrabackup_use_memory);
@@ -1547,7 +1548,8 @@ static int prepare_export()
15471548
" --defaults-file=./backup-my.cnf --defaults-group-suffix=%s --datadir=."
15481549
" --innodb --innodb-fast-shutdown=0 --loose-partition"
15491550
" --innodb_purge_rseg_truncate_frequency=1 --innodb-buffer-pool-size=%llu"
1550-
" --console --log-error= --bootstrap < " BOOTSTRAP_FILENAME IF_WIN("\"",""),
1551+
" --console --log-error= --skip-log-bin --bootstrap < "
1552+
BOOTSTRAP_FILENAME IF_WIN("\"",""),
15511553
mariabackup_exe,
15521554
(my_defaults_group_suffix?my_defaults_group_suffix:""),
15531555
xtrabackup_use_memory);

mysql-test/suite/mariabackup/partial.test

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ CREATE TABLE t2(i int) ENGINE INNODB;
1212

1313
echo # xtrabackup backup;
1414

15-
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
15+
let targetdir=$MYSQLTEST_VARDIR/tmp/backup;
1616
--disable_result_log
1717
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup "--tables=test.*1" --target-dir=$targetdir;
1818
--enable_result_log
@@ -25,13 +25,27 @@ EOF
2525
write_file $targetdir/test/junk.frm;
2626
EOF
2727

28+
let server_cnf=$targetdir/server.cnf;
29+
copy_file $MYSQLTEST_VARDIR/my.cnf $server_cnf;
30+
31+
# Emulate server config file turnes on binary logs
32+
perl;
33+
my $binlog_path="$ENV{'targetdir'}/mysqld-bin";
34+
my $config_path=$ENV{'server_cnf'};
35+
open(my $fd, '>>', "$config_path");
36+
print $fd "\n[mysqld]\n";
37+
print $fd "log-bin=$binlog_path\n";
38+
close $fd;
39+
EOF
2840

2941
echo # xtrabackup prepare;
3042
--disable_result_log
31-
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffix=.1 --prepare --export --target-dir=$targetdir;
43+
exec $XTRABACKUP --defaults-file=$server_cnf --defaults-group-suffix=.1 --prepare --export --target-dir=$targetdir;
3244
--enable_result_log
3345

3446
list_files $targetdir/test *.cfg;
47+
# There must not be binary logs created on --prepare step
48+
list_files $targetdir/ mysqld-bin.*;
3549

3650
let $MYSQLD_DATADIR= `select @@datadir`;
3751
ALTER TABLE t1 DISCARD TABLESPACE;

0 commit comments

Comments
 (0)