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.
This commit is contained in:
Julius Goryavsky 2022-07-19 13:26:19 +02:00
parent 5b4154373a
commit 7fb1f919d0
5 changed files with 35 additions and 32 deletions

View File

@ -53,28 +53,7 @@ COUNT(*) = 2
1 1
include/show_binlog_events.inc include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
hostname1-bin.000001 # Gtid # # GTID #-#-# hostname1-bin.000002 # Binlog_checkpoint # # hostname1-bin.000002
hostname1-bin.000001 # Query # # use `test`; CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB
hostname1-bin.000001 # Gtid # # BEGIN GTID #-#-#
hostname1-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES (1)
hostname1-bin.000001 # Table_map # # table_id: # (test.t1)
hostname1-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
hostname1-bin.000001 # Xid # # COMMIT /* XID */
hostname1-bin.000001 # Gtid # # GTID #-#-#
hostname1-bin.000001 # Query # # use `test`; CREATE TABLE t2 (id INT) ENGINE=InnoDB
hostname1-bin.000001 # Gtid # # BEGIN GTID #-#-#
hostname1-bin.000001 # Annotate_rows # # INSERT INTO t2 VALUES (1)
hostname1-bin.000001 # Table_map # # table_id: # (test.t2)
hostname1-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
hostname1-bin.000001 # Xid # # COMMIT /* XID */
hostname1-bin.000001 # Gtid # # BEGIN GTID #-#-#
hostname1-bin.000001 # Annotate_rows # # INSERT INTO t2 VALUES (1)
hostname1-bin.000001 # Table_map # # table_id: # (test.t2)
hostname1-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
hostname1-bin.000001 # Xid # # COMMIT /* XID */
hostname1-bin.000001 # Gtid # # GTID #-#-#
hostname1-bin.000001 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN f2 INTEGER
hostname1-bin.000001 # Rotate # # hostname1-bin.000002;pos=4
DROP TABLE t1; DROP TABLE t1;
DROP TABLE t2; DROP TABLE t2;
#cleanup #cleanup

View File

@ -71,7 +71,7 @@ then
# (b) Cluster state ID & wsrep_gtid_domain_id to be written to the file, OR # (b) Cluster state ID & wsrep_gtid_domain_id to be written to the file, OR
# (c) ERROR file, in case flush tables operation failed. # (c) ERROR file, in case flush tables operation failed.
while [ ! -r "$FLUSHED" ] && \ while [ ! -r "$FLUSHED" ] || \
! grep -q -F ':' -- "$FLUSHED" ! grep -q -F ':' -- "$FLUSHED"
do do
# Check whether ERROR file exists. # Check whether ERROR file exists.

View File

@ -104,6 +104,7 @@ WSREP_SST_OPT_HOST_UNESCAPED=""
INNODB_DATA_HOME_DIR=$(trim_dir "${INNODB_DATA_HOME_DIR:-}") INNODB_DATA_HOME_DIR=$(trim_dir "${INNODB_DATA_HOME_DIR:-}")
INNODB_LOG_GROUP_HOME=$(trim_dir "${INNODB_LOG_GROUP_HOME:-}") INNODB_LOG_GROUP_HOME=$(trim_dir "${INNODB_LOG_GROUP_HOME:-}")
INNODB_UNDO_DIR=$(trim_dir "${INNODB_UNDO_DIR:-}") INNODB_UNDO_DIR=$(trim_dir "${INNODB_UNDO_DIR:-}")
INNODB_BUFFER_POOL=""
INNODB_FORCE_RECOVERY="" INNODB_FORCE_RECOVERY=""
INNOEXTRA="" INNOEXTRA=""
@ -212,6 +213,10 @@ case "$1" in
readonly INNODB_UNDO_DIR=$(trim_dir "$2") readonly INNODB_UNDO_DIR=$(trim_dir "$2")
shift shift
;; ;;
'--innodb-buffer-pool-filename')
readonly INNODB_BUFFER_POOL=$(trim_string "$2")
shift
;;
'--defaults-file') '--defaults-file')
readonly WSREP_SST_OPT_DEFAULT="$1=$2" readonly WSREP_SST_OPT_DEFAULT="$1=$2"
readonly WSREP_SST_OPT_DEFAULTS="$1='$2'" readonly WSREP_SST_OPT_DEFAULTS="$1='$2'"
@ -471,6 +476,12 @@ case "$1" in
fi fi
skip_mysqld_arg=1 skip_mysqld_arg=1
;; ;;
'--innodb-buffer-pool-filename')
if [ -z "$INNODB_BUFFER_POOL" ]; then
MYSQLD_OPT_INNODB_BUFFER_POOL=$(trim_string "$value")
fi
skip_mysqld_arg=1
;;
'--innodb-force-recovery') '--innodb-force-recovery')
if [ -n "$value" -a "$value" != "0" ]; then if [ -n "$value" -a "$value" != "0" ]; then
INNODB_FORCE_RECOVERY=$(trim_string "$value") INNODB_FORCE_RECOVERY=$(trim_string "$value")
@ -552,6 +563,10 @@ if [ -n "${MYSQLD_OPT_INNODB_UNDO_DIR:-}" -a \
-z "$INNODB_UNDO_DIR" ]; then -z "$INNODB_UNDO_DIR" ]; then
readonly INNODB_UNDO_DIR="$MYSQLD_OPT_INNODB_UNDO_DIR" readonly INNODB_UNDO_DIR="$MYSQLD_OPT_INNODB_UNDO_DIR"
fi fi
if [ -n "${MYSQLD_OPT_INNODB_BUFFER_POOL:-}" -a \
-z "$INNODB_BUFFER_POOL" ]; then
readonly INNODB_BUFFER_POOL="$MYSQLD_OPT_INNODB_BUFFER_POOL"
fi
if [ -n "${MYSQLD_OPT_LOG_BIN:-}" -a \ if [ -n "${MYSQLD_OPT_LOG_BIN:-}" -a \
-z "$WSREP_SST_OPT_BINLOG" ]; then -z "$WSREP_SST_OPT_BINLOG" ]; then
readonly WSREP_SST_OPT_BINLOG="$MYSQLD_OPT_LOG_BIN" readonly WSREP_SST_OPT_BINLOG="$MYSQLD_OPT_LOG_BIN"
@ -602,6 +617,9 @@ fi
if [ -n "$INNODB_UNDO_DIR" ]; then if [ -n "$INNODB_UNDO_DIR" ]; then
INNOEXTRA="$INNOEXTRA --innodb-undo-directory='$INNODB_UNDO_DIR'" INNOEXTRA="$INNOEXTRA --innodb-undo-directory='$INNODB_UNDO_DIR'"
fi fi
if [ -n "$INNODB_BUFFER_POOL" ]; then
INNOEXTRA="$INNOEXTRA --innodb-buffer-pool-filename='$INNODB_BUFFER_POOL'"
fi
if [ -n "$WSREP_SST_OPT_BINLOG" ]; then if [ -n "$WSREP_SST_OPT_BINLOG" ]; then
INNOEXTRA="$INNOEXTRA --log-bin='$WSREP_SST_OPT_BINLOG'" INNOEXTRA="$INNOEXTRA --log-bin='$WSREP_SST_OPT_BINLOG'"
if [ -n "$WSREP_SST_OPT_BINLOG_INDEX" ]; then if [ -n "$WSREP_SST_OPT_BINLOG_INDEX" ]; then

View File

@ -664,6 +664,9 @@ cleanup_at_exit()
local estatus=$? local estatus=$?
if [ $estatus -ne 0 ]; then if [ $estatus -ne 0 ]; then
wsrep_log_error "Cleanup after exit with status: $estatus" wsrep_log_error "Cleanup after exit with status: $estatus"
elif [ -z "${coords:-}" -a "$WSREP_SST_OPT_ROLE" = 'joiner' ]; then
estatus=32
wsrep_log_error "Failed to get current position"
fi fi
[ "$(pwd)" != "$OLD_PWD" ] && cd "$OLD_PWD" [ "$(pwd)" != "$OLD_PWD" ] && cd "$OLD_PWD"
@ -934,6 +937,11 @@ if [ $ssyslog -eq 1 ]; then
logger -p daemon.err -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE "$@" logger -p daemon.err -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE "$@"
} }
wsrep_log_warning()
{
logger -p daemon.warning -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE "$@"
}
wsrep_log_info() wsrep_log_info()
{ {
logger -p daemon.info -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE "$@" logger -p daemon.info -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE "$@"
@ -1015,7 +1023,7 @@ setup_commands()
recovery=" --innodb-force-recovery=$INNODB_FORCE_RECOVERY" recovery=" --innodb-force-recovery=$INNODB_FORCE_RECOVERY"
fi fi
INNOAPPLY="$BACKUP_BIN --prepare$disver$recovery${iapts:+ }$iapts$INNOEXTRA --target-dir='$DATA' --datadir='$DATA'$mysqld_args $INNOAPPLY" INNOAPPLY="$BACKUP_BIN --prepare$disver$recovery${iapts:+ }$iapts$INNOEXTRA --target-dir='$DATA' --datadir='$DATA'$mysqld_args $INNOAPPLY"
INNOMOVE="$BACKUP_BIN$WSREP_SST_OPT_CONF --move-back$disver${impts:+ }$impts$INNOEXTRA --force-non-empty-directories --target-dir='$DATA' --datadir='${TDATA:-$DATA}' $INNOMOVE" 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"
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" 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"
} }
@ -1153,11 +1161,6 @@ if [ "$WSREP_SST_OPT_ROLE" = 'donor' ]; then
iopts="--parallel=$backup_threads${iopts:+ }$iopts" iopts="--parallel=$backup_threads${iopts:+ }$iopts"
fi fi
max_binlogs=$(parse_cnf "$encgroups" 'sst-max-binlogs')
if [ -n "$max_binlogs" ]; then
iopts="--sst-max-binlogs=$max_binlogs${iopts:+ }$iopts"
fi
setup_commands setup_commands
set +e set +e

View File

@ -38,6 +38,9 @@ cleanup_joiner()
local estatus=$? local estatus=$?
if [ $estatus -ne 0 ]; then if [ $estatus -ne 0 ]; then
wsrep_log_error "Cleanup after exit with status: $estatus" wsrep_log_error "Cleanup after exit with status: $estatus"
elif [ -z "${coords:-}" ]; then
estatus=32
wsrep_log_error "Failed to get current position"
fi fi
local failure=0 local failure=0
@ -408,7 +411,7 @@ EOF
# (b) Cluster state ID & wsrep_gtid_domain_id to be written to the file, OR # (b) Cluster state ID & wsrep_gtid_domain_id to be written to the file, OR
# (c) ERROR file, in case flush tables operation failed. # (c) ERROR file, in case flush tables operation failed.
while [ ! -r "$FLUSHED" ] && \ while [ ! -r "$FLUSHED" ] || \
! grep -q -F ':' -- "$FLUSHED" ! grep -q -F ':' -- "$FLUSHED"
do do
# Check whether ERROR file exists. # Check whether ERROR file exists.
@ -433,8 +436,8 @@ EOF
# Let's check the existence of the file with the index: # Let's check the existence of the file with the index:
if [ -f "$WSREP_SST_OPT_BINLOG_INDEX" ]; then if [ -f "$WSREP_SST_OPT_BINLOG_INDEX" ]; then
# Let's read the binlog index: # Let's read the binlog index:
max_binlogs=$(parse_cnf "$encgroups" 'sst-max-binlogs') max_binlogs=$(parse_cnf "$encgroups" 'sst-max-binlogs' 1)
if [ -n "$max_binlogs" ]; then if [ $max_binlogs -ge 0 ]; then
binlog_files="" binlog_files=""
if [ $max_binlogs -gt 0 ]; then if [ $max_binlogs -gt 0 ]; then
binlog_files=$(tail -n $max_binlogs \ binlog_files=$(tail -n $max_binlogs \