Skip to content

Commit 7fb1f91

Browse files
committed
MDEV-28758: Mariabackup copies binary logs to backup directory
This commit restores defaults and functionality regarding binlogs to the way it was prior to MDEV-27524. The mariabackup utility no longer saves binlogs files as part of a backup without the --galera-info option. However, since we use --galera-info during SST, the behavior of mariabackup changes and, in combination with GTIDs support enabled, mariabackup transfers one (most recent) binlog file obtained after FLUSH BINARY LOGS. In other cases, binlogs are not transferred during SST in mariabackup mode. As for SST in the rsync mode, it works the same way as before MDEV-27524 - by default it transfers one last binlog file. The --sst-max-binlogs option for mariabackup and the sst_max_binlogs parameter in the [sst] / server sections are no longer supported for SST via mariabackup.
1 parent 5b41543 commit 7fb1f91

File tree

5 files changed

+35
-32
lines changed

5 files changed

+35
-32
lines changed

mysql-test/suite/galera/r/galera_log_bin_ext.result

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,28 +53,7 @@ COUNT(*) = 2
5353
1
5454
include/show_binlog_events.inc
5555
Log_name Pos Event_type Server_id End_log_pos Info
56-
hostname1-bin.000001 # Gtid # # GTID #-#-#
57-
hostname1-bin.000001 # Query # # use `test`; CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB
58-
hostname1-bin.000001 # Gtid # # BEGIN GTID #-#-#
59-
hostname1-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES (1)
60-
hostname1-bin.000001 # Table_map # # table_id: # (test.t1)
61-
hostname1-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
62-
hostname1-bin.000001 # Xid # # COMMIT /* XID */
63-
hostname1-bin.000001 # Gtid # # GTID #-#-#
64-
hostname1-bin.000001 # Query # # use `test`; CREATE TABLE t2 (id INT) ENGINE=InnoDB
65-
hostname1-bin.000001 # Gtid # # BEGIN GTID #-#-#
66-
hostname1-bin.000001 # Annotate_rows # # INSERT INTO t2 VALUES (1)
67-
hostname1-bin.000001 # Table_map # # table_id: # (test.t2)
68-
hostname1-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
69-
hostname1-bin.000001 # Xid # # COMMIT /* XID */
70-
hostname1-bin.000001 # Gtid # # BEGIN GTID #-#-#
71-
hostname1-bin.000001 # Annotate_rows # # INSERT INTO t2 VALUES (1)
72-
hostname1-bin.000001 # Table_map # # table_id: # (test.t2)
73-
hostname1-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
74-
hostname1-bin.000001 # Xid # # COMMIT /* XID */
75-
hostname1-bin.000001 # Gtid # # GTID #-#-#
76-
hostname1-bin.000001 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN f2 INTEGER
77-
hostname1-bin.000001 # Rotate # # hostname1-bin.000002;pos=4
56+
hostname1-bin.000002 # Binlog_checkpoint # # hostname1-bin.000002
7857
DROP TABLE t1;
7958
DROP TABLE t2;
8059
#cleanup

scripts/wsrep_sst_backup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ then
7171
# (b) Cluster state ID & wsrep_gtid_domain_id to be written to the file, OR
7272
# (c) ERROR file, in case flush tables operation failed.
7373

74-
while [ ! -r "$FLUSHED" ] && \
74+
while [ ! -r "$FLUSHED" ] || \
7575
! grep -q -F ':' -- "$FLUSHED"
7676
do
7777
# Check whether ERROR file exists.

scripts/wsrep_sst_common.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ WSREP_SST_OPT_HOST_UNESCAPED=""
104104
INNODB_DATA_HOME_DIR=$(trim_dir "${INNODB_DATA_HOME_DIR:-}")
105105
INNODB_LOG_GROUP_HOME=$(trim_dir "${INNODB_LOG_GROUP_HOME:-}")
106106
INNODB_UNDO_DIR=$(trim_dir "${INNODB_UNDO_DIR:-}")
107+
INNODB_BUFFER_POOL=""
107108
INNODB_FORCE_RECOVERY=""
108109
INNOEXTRA=""
109110

@@ -212,6 +213,10 @@ case "$1" in
212213
readonly INNODB_UNDO_DIR=$(trim_dir "$2")
213214
shift
214215
;;
216+
'--innodb-buffer-pool-filename')
217+
readonly INNODB_BUFFER_POOL=$(trim_string "$2")
218+
shift
219+
;;
215220
'--defaults-file')
216221
readonly WSREP_SST_OPT_DEFAULT="$1=$2"
217222
readonly WSREP_SST_OPT_DEFAULTS="$1='$2'"
@@ -471,6 +476,12 @@ case "$1" in
471476
fi
472477
skip_mysqld_arg=1
473478
;;
479+
'--innodb-buffer-pool-filename')
480+
if [ -z "$INNODB_BUFFER_POOL" ]; then
481+
MYSQLD_OPT_INNODB_BUFFER_POOL=$(trim_string "$value")
482+
fi
483+
skip_mysqld_arg=1
484+
;;
474485
'--innodb-force-recovery')
475486
if [ -n "$value" -a "$value" != "0" ]; then
476487
INNODB_FORCE_RECOVERY=$(trim_string "$value")
@@ -552,6 +563,10 @@ if [ -n "${MYSQLD_OPT_INNODB_UNDO_DIR:-}" -a \
552563
-z "$INNODB_UNDO_DIR" ]; then
553564
readonly INNODB_UNDO_DIR="$MYSQLD_OPT_INNODB_UNDO_DIR"
554565
fi
566+
if [ -n "${MYSQLD_OPT_INNODB_BUFFER_POOL:-}" -a \
567+
-z "$INNODB_BUFFER_POOL" ]; then
568+
readonly INNODB_BUFFER_POOL="$MYSQLD_OPT_INNODB_BUFFER_POOL"
569+
fi
555570
if [ -n "${MYSQLD_OPT_LOG_BIN:-}" -a \
556571
-z "$WSREP_SST_OPT_BINLOG" ]; then
557572
readonly WSREP_SST_OPT_BINLOG="$MYSQLD_OPT_LOG_BIN"
@@ -602,6 +617,9 @@ fi
602617
if [ -n "$INNODB_UNDO_DIR" ]; then
603618
INNOEXTRA="$INNOEXTRA --innodb-undo-directory='$INNODB_UNDO_DIR'"
604619
fi
620+
if [ -n "$INNODB_BUFFER_POOL" ]; then
621+
INNOEXTRA="$INNOEXTRA --innodb-buffer-pool-filename='$INNODB_BUFFER_POOL'"
622+
fi
605623
if [ -n "$WSREP_SST_OPT_BINLOG" ]; then
606624
INNOEXTRA="$INNOEXTRA --log-bin='$WSREP_SST_OPT_BINLOG'"
607625
if [ -n "$WSREP_SST_OPT_BINLOG_INDEX" ]; then

scripts/wsrep_sst_mariabackup.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,9 @@ cleanup_at_exit()
664664
local estatus=$?
665665
if [ $estatus -ne 0 ]; then
666666
wsrep_log_error "Cleanup after exit with status: $estatus"
667+
elif [ -z "${coords:-}" -a "$WSREP_SST_OPT_ROLE" = 'joiner' ]; then
668+
estatus=32
669+
wsrep_log_error "Failed to get current position"
667670
fi
668671

669672
[ "$(pwd)" != "$OLD_PWD" ] && cd "$OLD_PWD"
@@ -934,6 +937,11 @@ if [ $ssyslog -eq 1 ]; then
934937
logger -p daemon.err -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE "$@"
935938
}
936939

940+
wsrep_log_warning()
941+
{
942+
logger -p daemon.warning -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE "$@"
943+
}
944+
937945
wsrep_log_info()
938946
{
939947
logger -p daemon.info -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE "$@"
@@ -1015,7 +1023,7 @@ setup_commands()
10151023
recovery=" --innodb-force-recovery=$INNODB_FORCE_RECOVERY"
10161024
fi
10171025
INNOAPPLY="$BACKUP_BIN --prepare$disver$recovery${iapts:+ }$iapts$INNOEXTRA --target-dir='$DATA' --datadir='$DATA'$mysqld_args $INNOAPPLY"
1018-
INNOMOVE="$BACKUP_BIN$WSREP_SST_OPT_CONF --move-back$disver${impts:+ }$impts$INNOEXTRA --force-non-empty-directories --target-dir='$DATA' --datadir='${TDATA:-$DATA}' $INNOMOVE"
1026+
INNOMOVE="$BACKUP_BIN$WSREP_SST_OPT_CONF --move-back$disver${impts:+ }$impts$INNOEXTRA --galera-info --force-non-empty-directories --target-dir='$DATA' --datadir='${TDATA:-$DATA}' $INNOMOVE"
10191027
INNOBACKUP="$BACKUP_BIN$WSREP_SST_OPT_CONF --backup$disver${iopts:+ }$iopts$tmpopts$INNOEXTRA --galera-info --stream=$sfmt --target-dir='$itmpdir' --datadir='$DATA'$mysqld_args $INNOBACKUP"
10201028
}
10211029

@@ -1153,11 +1161,6 @@ if [ "$WSREP_SST_OPT_ROLE" = 'donor' ]; then
11531161
iopts="--parallel=$backup_threads${iopts:+ }$iopts"
11541162
fi
11551163

1156-
max_binlogs=$(parse_cnf "$encgroups" 'sst-max-binlogs')
1157-
if [ -n "$max_binlogs" ]; then
1158-
iopts="--sst-max-binlogs=$max_binlogs${iopts:+ }$iopts"
1159-
fi
1160-
11611164
setup_commands
11621165

11631166
set +e

scripts/wsrep_sst_rsync.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ cleanup_joiner()
3838
local estatus=$?
3939
if [ $estatus -ne 0 ]; then
4040
wsrep_log_error "Cleanup after exit with status: $estatus"
41+
elif [ -z "${coords:-}" ]; then
42+
estatus=32
43+
wsrep_log_error "Failed to get current position"
4144
fi
4245

4346
local failure=0
@@ -408,7 +411,7 @@ EOF
408411
# (b) Cluster state ID & wsrep_gtid_domain_id to be written to the file, OR
409412
# (c) ERROR file, in case flush tables operation failed.
410413

411-
while [ ! -r "$FLUSHED" ] && \
414+
while [ ! -r "$FLUSHED" ] || \
412415
! grep -q -F ':' -- "$FLUSHED"
413416
do
414417
# Check whether ERROR file exists.
@@ -433,8 +436,8 @@ EOF
433436
# Let's check the existence of the file with the index:
434437
if [ -f "$WSREP_SST_OPT_BINLOG_INDEX" ]; then
435438
# Let's read the binlog index:
436-
max_binlogs=$(parse_cnf "$encgroups" 'sst-max-binlogs')
437-
if [ -n "$max_binlogs" ]; then
439+
max_binlogs=$(parse_cnf "$encgroups" 'sst-max-binlogs' 1)
440+
if [ $max_binlogs -ge 0 ]; then
438441
binlog_files=""
439442
if [ $max_binlogs -gt 0 ]; then
440443
binlog_files=$(tail -n $max_binlogs \

0 commit comments

Comments
 (0)