From e51a1d6fc0c105d56c6f05efb3d9fd05b7e4f22f Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Tue, 3 Jan 2023 10:48:57 +1100 Subject: MDEV-30329: mariadb-service-convert resets systemd service to default User=root If mariadb-service-convert is run and the user variable is unset then this sets `User=` in `[Service]`, which then tries to run mariadb as root, which in-turn fails. This only happens when mysqld_safe is missing which is all the time now. So don't set `User=` if there is no user variable. Reviewer: Sergei Golubchik (in PR #2382) --- scripts/mariadb-service-convert | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/mariadb-service-convert b/scripts/mariadb-service-convert index 38043733554..ade07e9a336 100755 --- a/scripts/mariadb-service-convert +++ b/scripts/mariadb-service-convert @@ -36,7 +36,7 @@ echo '[Service]' echo -if [[ ( "$user" != "root" && "$user" != "mysql" ) || "${SET_USER}" == 1 ]]; then +if [[ ( ! -z "$user" && "$user" != "root" && "$user" != "mysql" ) || "${SET_USER}" == 1 ]]; then echo User=$user fi -- cgit v1.2.1 From e4a4aad7cf5a8cdb3ae4d97527f489cc590146a1 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Tue, 13 Dec 2022 10:32:21 +0100 Subject: pre-MDEV-30157 & pre-MDEV-28669: fixes before the main corrections This commit adds even more correct handling of parameters with paths when they contain leading or trailing spaces and/or slashes. Also it fixes problems that occur when the user specified explicit paths to additional directories, but these paths match the specified path of the data directory - in this case, additional subdirectories should be treated (in relation to the data directory) in the same way as if these paths were not specified or as if they are implicitly specified as "." or "./". But prior to this fix, existing code treated any values as if they were completely separate directories, whether or not they actually point to the same location to which datadir points to - and this sometimes resulted in incorrect file transfers. This fix does not contain separate tests, as tests will be part of the main commit(s). This fix has been made as a separate commit to facilitate review for major substantive fixes related to MDEV-30157 and MDEV-28669. --- scripts/wsrep_sst_common.sh | 113 ++++++++++++++++++++++++++------------- scripts/wsrep_sst_mariabackup.sh | 30 ++++++++--- scripts/wsrep_sst_rsync.sh | 26 ++++++--- 3 files changed, 118 insertions(+), 51 deletions(-) (limited to 'scripts') diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index 6a94cb0f706..407a4c9dd24 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -47,18 +47,51 @@ trim_string() trim_dir() { - local t=$(trim_string "$1") - if [ "$t" != '/' ]; then - if [ "${t%/}" != "$t" ]; then - t=$(trim_string "${t%/}") + if [ -n "$BASH_VERSION" ]; then + local pattern="![:space:]${2:-}" + local x="${1#*[$pattern]}" + local z=${#1} + x=${#x} + if [ $x -ne $z ]; then + local y="${1%[$pattern/]*}" + y=${#y} + x=$(( z-x-1 )) + y=$(( y-x+1 )) + x="${1:$x:$y}" + [ -z "$x" ] && x='.' + printf '%s' "$x" + else + printf '' fi else - t='.' + local pattern="[:space:]${2:-}" + local x=$(echo "$1" | sed -E "s/^[$pattern]+|[$pattern/]+\$//g") + if [ -n "$x" ]; then + echo "$x" + elif "${1#*/}" != "$1"; then + echo '.' + else + echo '' + fi fi +} + +trim_right() +{ if [ -n "$BASH_VERSION" ]; then - printf '%s' "$t" + local pattern="[![:space:]${2:-}]" + local z=${#1} + local y="${1%$pattern*}" + y=${#y} + if [ $y -ne $z ]; then + y=$(( y+1 )) + printf '%s' "${1:0:$y}" + else + printf '' + fi else - echo "$t" + local pattern="[[:space:]${2:-}]" + echo "$1" | sed -E "s/$pattern+\$//g" fi } @@ -111,7 +144,7 @@ INNOEXTRA="" while [ $# -gt 0 ]; do case "$1" in '--address') - WSREP_SST_OPT_ADDR="$2" + WSREP_SST_OPT_ADDR=$(trim_string "$2") # # Break address string into host:port/path parts # @@ -119,20 +152,22 @@ case "$1" in \[*) # IPv6 # Remove the starting and ending square brackets, if present: - addr_no_bracket="${WSREP_SST_OPT_ADDR#\[}" + addr="${WSREP_SST_OPT_ADDR#\[}" + addr=$(trim_right "${addr%%\]*}") # Some utilities and subsequent code require an address # without square brackets: - readonly WSREP_SST_OPT_HOST_UNESCAPED="${addr_no_bracket%%\]*}" + readonly WSREP_SST_OPT_HOST_UNESCAPED="$addr" # Square brackets are needed in most cases: - readonly WSREP_SST_OPT_HOST="[$WSREP_SST_OPT_HOST_UNESCAPED]" + readonly WSREP_SST_OPT_HOST="[$addr]" # Mark this address as IPv6: readonly WSREP_SST_OPT_HOST_IPv6=1 # Let's remove the leading part that contains the host address: remain="${WSREP_SST_OPT_ADDR#*\]}" ;; *) - readonly WSREP_SST_OPT_HOST="${WSREP_SST_OPT_ADDR%%[:/]*}" - readonly WSREP_SST_OPT_HOST_UNESCAPED="$WSREP_SST_OPT_HOST" + addr=$(trim_right "${WSREP_SST_OPT_ADDR%%[:/]*}") + readonly WSREP_SST_OPT_HOST="$addr" + readonly WSREP_SST_OPT_HOST_UNESCAPED="$addr" readonly WSREP_SST_OPT_HOST_IPv6=0 # Let's remove the leading part that contains the host address: remain="${WSREP_SST_OPT_ADDR#*[:/]}" @@ -154,17 +189,18 @@ case "$1" in else readonly WSREP_SST_OPT_PATH="" fi + WSREP_SST_OPT_ADDR_PORT=$(trim_right "$WSREP_SST_OPT_ADDR_PORT") # Remove the module name part from the string, which ends with "/": remain="${WSREP_SST_OPT_PATH#*/}" # This operation removes the tail after the very first occurrence # of the "/" character, inclusively: - readonly WSREP_SST_OPT_MODULE="${WSREP_SST_OPT_PATH%%/*}" + readonly WSREP_SST_OPT_MODULE=$(trim_right "${WSREP_SST_OPT_PATH%%/*}") # If there is one more "/" in the string, then everything before # it will be the LSN, otherwise the LSN is empty: if [ "$remain" != "$WSREP_SST_OPT_PATH" ]; then # Extract the part that matches the LSN by removing all # characters starting from the very first "/": - readonly WSREP_SST_OPT_LSN="${remain%%/*}" + readonly WSREP_SST_OPT_LSN=$(trim_right "${remain%%/*}") # Exctract everything after the first occurrence of # the "/" character in the string: source="$remain" @@ -176,7 +212,7 @@ case "$1" in # Let's extract the version number by removing the tail # after the very first occurence of the "/" character # (inclusively): - readonly WSREP_SST_OPT_SST_VER="${remain%%/*}" + readonly WSREP_SST_OPT_SST_VER=$(trim_right "${remain%%/*}") else readonly WSREP_SST_OPT_SST_VER="" fi @@ -218,41 +254,46 @@ case "$1" in shift ;; '--defaults-file') - readonly WSREP_SST_OPT_DEFAULT="$1=$2" - readonly WSREP_SST_OPT_DEFAULTS="$1='$2'" + file=$(trim_string "$2") + readonly WSREP_SST_OPT_DEFAULT="$1=$file" + readonly WSREP_SST_OPT_DEFAULTS="$1='$file'" shift ;; '--defaults-extra-file') - readonly WSREP_SST_OPT_EXTRA_DEFAULT="$1=$2" - readonly WSREP_SST_OPT_EXTRA_DEFAULTS="$1='$2'" + file=$(trim_string "$2") + readonly WSREP_SST_OPT_EXTRA_DEFAULT="$1=$file" + readonly WSREP_SST_OPT_EXTRA_DEFAULTS="$1='$file'" shift ;; '--defaults-group-suffix') - readonly WSREP_SST_OPT_SUFFIX_DEFAULT="$1=$2" - readonly WSREP_SST_OPT_SUFFIX_VALUE="$2" + suffix=$(trim_string "$2") + readonly WSREP_SST_OPT_SUFFIX_DEFAULT="$1=$suffix" + readonly WSREP_SST_OPT_SUFFIX_VALUE="$suffix" shift ;; '--host') - case "$2" in + addr=$(trim_string "$2") + case "$addr" in \[*) # IPv6 # Remove the starting and ending square brackets, if present: - addr_no_bracket="${2#\[}" + addr="${addr#\[}" + addr=$(trim_right "${addr%%\]*}") # Some utilities and subsequent code require an address # without square brackets: - readonly WSREP_SST_OPT_HOST_UNESCAPED="${addr_no_bracket%%\]*}" + readonly WSREP_SST_OPT_HOST_UNESCAPED="$addr" # Square brackets are needed in most cases: - readonly WSREP_SST_OPT_HOST="[${WSREP_SST_OPT_HOST_UNESCAPED}]" + readonly WSREP_SST_OPT_HOST="[$addr]" # Mark this address as IPv6: readonly WSREP_SST_OPT_HOST_IPv6=1 ;; *) - readonly WSREP_SST_OPT_HOST="$2" - readonly WSREP_SST_OPT_HOST_UNESCAPED="$2" + readonly WSREP_SST_OPT_HOST="$addr" + readonly WSREP_SST_OPT_HOST_UNESCAPED="$addr" readonly WSREP_SST_OPT_HOST_IPv6=0 ;; esac - WSREP_SST_OPT_ADDR="$WSREP_SST_OPT_HOST" + WSREP_SST_OPT_ADDR="$addr" shift ;; '--local-port') @@ -272,11 +313,11 @@ case "$1" in shift ;; '--role') - readonly WSREP_SST_OPT_ROLE="$2" + readonly WSREP_SST_OPT_ROLE=$(trim_string "$2") shift ;; '--socket') - readonly WSREP_SST_OPT_SOCKET="$2" + readonly WSREP_SST_OPT_SOCKET=$(trim_string "$2") shift ;; '--user') @@ -284,23 +325,23 @@ case "$1" in shift ;; '--gtid') - readonly WSREP_SST_OPT_GTID="$2" + readonly WSREP_SST_OPT_GTID=$(trim_string "$2") shift ;; '--binlog'|'--log-bin') - readonly WSREP_SST_OPT_BINLOG="$2" + readonly WSREP_SST_OPT_BINLOG=$(trim_string "$2") shift ;; '--binlog-index'|'--log-bin-index') - WSREP_SST_OPT_BINLOG_INDEX="$2" + WSREP_SST_OPT_BINLOG_INDEX=$(trim_string "$2") shift ;; '--log-basename') - readonly WSREP_SST_OPT_LOG_BASENAME="$2" + readonly WSREP_SST_OPT_LOG_BASENAME=$(trim_string "$2") shift ;; '--gtid-domain-id') - readonly WSREP_SST_OPT_GTID_DOMAIN_ID="$2" + readonly WSREP_SST_OPT_GTID_DOMAIN_ID=$(trim_string "$2") shift ;; '--mysqld-args') diff --git a/scripts/wsrep_sst_mariabackup.sh b/scripts/wsrep_sst_mariabackup.sh index 63ef8be8690..7465b2a3b08 100644 --- a/scripts/wsrep_sst_mariabackup.sh +++ b/scripts/wsrep_sst_mariabackup.sh @@ -439,9 +439,10 @@ get_footprint() -regex '.*undo[0-9]+$\|.*\.ibd$\|.*\.MYI$\|.*\.MYD$\|.*ibdata1$' \ -type f -print0 | du --files0-from=- --block-size=1 -c -s | \ awk 'END { print $1 }') - local payload_undo=0 - if [ -n "$ib_undo_dir" -a -d "$ib_undo_dir" ]; then + if [ -n "$ib_undo_dir" -a "$ib_undo_dir" != '.' -a \ + "$ib_undo_dir" != "$DATA_DIR" -a -d "$ib_undo_dir" ] + then cd "$ib_undo_dir" payload_undo=$(find . -regex '.*undo[0-9]+$' -type f -print0 | \ du --files0-from=- --block-size=1 -c -s | awk 'END { print $1 }') @@ -451,7 +452,7 @@ get_footprint() wsrep_log_info \ "SST footprint estimate: data: $payload_data, undo: $payload_undo" - payload=$(( payload_data + payload_undo )) + payload=$(( payload_data+payload_undo )) if [ "$compress" != 'none' ]; then # QuickLZ has around 50% compression ratio @@ -1220,13 +1221,16 @@ else # joiner INNODB_DATA_HOME_DIR=$(trim_dir "$INNODB_DATA_HOME_DIR") fi - if [ -n "$INNODB_DATA_HOME_DIR" -a "$INNODB_DATA_HOME_DIR" != '.' ]; then + if [ -n "$INNODB_DATA_HOME_DIR" -a "$INNODB_DATA_HOME_DIR" != '.' -a \ + "$INNODB_DATA_HOME_DIR" != "$DATA_DIR" ] + then # handle both relative and absolute paths: cd "$DATA" [ ! -d "$INNODB_DATA_HOME_DIR" ] && mkdir -p "$INNODB_DATA_HOME_DIR" cd "$INNODB_DATA_HOME_DIR" ib_home_dir="$(pwd)" cd "$OLD_PWD" + [ "$ib_home_dir" = "$DATA_DIR" ] && ib_home_dir="" fi # if no command line argument and INNODB_LOG_GROUP_HOME is not set, @@ -1236,13 +1240,16 @@ else # joiner INNODB_LOG_GROUP_HOME=$(trim_dir "$INNODB_LOG_GROUP_HOME") fi - if [ -n "$INNODB_LOG_GROUP_HOME" -a "$INNODB_LOG_GROUP_HOME" != '.' ]; then + if [ -n "$INNODB_LOG_GROUP_HOME" -a "$INNODB_LOG_GROUP_HOME" != '.' -a \ + "$INNODB_LOG_GROUP_HOME" != "$DATA_DIR" ] + then # handle both relative and absolute paths: cd "$DATA" [ ! -d "$INNODB_LOG_GROUP_HOME" ] && mkdir -p "$INNODB_LOG_GROUP_HOME" cd "$INNODB_LOG_GROUP_HOME" ib_log_dir="$(pwd)" cd "$OLD_PWD" + [ "$ib_log_dir" = "$DATA_DIR" ] && ib_log_dir="" fi # if no command line argument and INNODB_UNDO_DIR is not set, @@ -1252,13 +1259,16 @@ else # joiner INNODB_UNDO_DIR=$(trim_dir "$INNODB_UNDO_DIR") fi - if [ -n "$INNODB_UNDO_DIR" -a "$INNODB_UNDO_DIR" != '.' ]; then + if [ -n "$INNODB_UNDO_DIR" -a "$INNODB_UNDO_DIR" != '.' -a \ + "$INNODB_UNDO_DIR" != "$DATA_DIR" ] + then # handle both relative and absolute paths: cd "$DATA" [ ! -d "$INNODB_UNDO_DIR" ] && mkdir -p "$INNODB_UNDO_DIR" cd "$INNODB_UNDO_DIR" ib_undo_dir="$(pwd)" cd "$OLD_PWD" + [ "$ib_undo_dir" = "$DATA_DIR" ] && ib_undo_dir="" fi if [ -n "$backup_threads" ]; then @@ -1500,11 +1510,15 @@ else # joiner binlogs=$(ls -d -1 "$binlog_base".[0-9]* 2>/dev/null || :) fi cd "$DATA_DIR" - if [ -n "$binlog_dir" -a "$binlog_dir" != '.' ]; then + if [ -n "$binlog_dir" -a "$binlog_dir" != '.' -a \ + "$binlog_dir" != "$DATA_DIR" ] + then [ ! -d "$binlog_dir" ] && mkdir -p "$binlog_dir" fi index_dir=$(dirname "$binlog_index"); - if [ -n "$index_dir" -a "$index_dir" != '.' ]; then + if [ -n "$index_dir" -a "$index_dir" != '.' -a \ + "$index_dir" != "$DATA_DIR" ] + then [ ! -d "$index_dir" ] && mkdir -p "$index_dir" fi if [ -n "$binlogs" ]; then diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index ddf41559c29..ee3e848025b 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -185,7 +185,9 @@ if [ -z "$INNODB_LOG_GROUP_HOME" ]; then INNODB_LOG_GROUP_HOME=$(trim_dir "$INNODB_LOG_GROUP_HOME") fi -if [ -n "$INNODB_LOG_GROUP_HOME" -a "$INNODB_LOG_GROUP_HOME" != '.' ]; then +if [ -n "$INNODB_LOG_GROUP_HOME" -a "$INNODB_LOG_GROUP_HOME" != '.' -a \ + "$INNODB_LOG_GROUP_HOME" != "$DATA_DIR" ] +then # handle both relative and absolute paths: cd "$DATA" [ ! -d "$INNODB_LOG_GROUP_HOME" ] && mkdir -p "$INNODB_LOG_GROUP_HOME" @@ -201,7 +203,9 @@ if [ -z "$INNODB_DATA_HOME_DIR" ]; then INNODB_DATA_HOME_DIR=$(trim_dir "$INNODB_DATA_HOME_DIR") fi -if [ -n "$INNODB_DATA_HOME_DIR" -a "$INNODB_DATA_HOME_DIR" != '.' ]; then +if [ -n "$INNODB_DATA_HOME_DIR" -a "$INNODB_DATA_HOME_DIR" != '.' -a \ + "$INNODB_DATA_HOME_DIR" != "$DATA_DIR" ] +then # handle both relative and absolute paths: cd "$DATA" [ ! -d "$INNODB_DATA_HOME_DIR" ] && mkdir -p "$INNODB_DATA_HOME_DIR" @@ -217,7 +221,9 @@ if [ -z "$INNODB_UNDO_DIR" ]; then INNODB_UNDO_DIR=$(trim_dir "$INNODB_UNDO_DIR") fi -if [ -n "$INNODB_UNDO_DIR" -a "$INNODB_UNDO_DIR" != '.' ]; then +if [ -n "$INNODB_UNDO_DIR" -a "$INNODB_UNDO_DIR" != '.' -a \ + "$INNODB_UNDO_DIR" != "$DATA_DIR" ] +then # handle both relative and absolute paths: cd "$DATA" [ ! -d "$INNODB_UNDO_DIR" ] && mkdir -p "$INNODB_UNDO_DIR" @@ -504,7 +510,9 @@ EOF if [ "$first" = '-' -o "$first" = '@' ]; then bin_base="./$bin_base" fi - if [ -n "$bin_dir" -a "$bin_dir" != '.' ]; then + if [ -n "$bin_dir" -a "$bin_dir" != '.' -a \ + "$bin_dir" != "$DATA_DIR" ] + then tar $tar_options "$BINLOG_TAR_FILE" \ -C "$bin_dir" "$bin_base" >&2 else @@ -872,7 +880,7 @@ EOF binlog_cd=0 # Change the directory to binlog base (if possible): if [ -n "$binlog_dir" -a "$binlog_dir" != '.' -a \ - -d "$binlog_dir" ] + "$binlog_dir" != "$DATA_DIR" -a -d "$binlog_dir" ] then binlog_cd=1 cd "$binlog_dir" @@ -891,11 +899,15 @@ EOF tmpfile=$(TMPDIR="$tmpdir"; mktemp) fi index_dir=$(dirname "$binlog_index"); - if [ -n "$index_dir" -a "$index_dir" != '.' ]; then + if [ -n "$index_dir" -a "$index_dir" != '.' -a \ + "$index_dir" != "$DATA_DIR" ] + then [ ! -d "$index_dir" ] && mkdir -p "$index_dir" fi binlog_cd=0 - if [ -n "$binlog_dir" -a "$binlog_dir" != '.' ]; then + if [ -n "$binlog_dir" -a "$binlog_dir" != '.' -a \ + "$binlog_dir" != "$DATA_DIR" ] + then [ ! -d "$binlog_dir" ] && mkdir -p "$binlog_dir" binlog_cd=1 cd "$binlog_dir" -- cgit v1.2.1 From b84f3fa769228c4ffd367bc8f2426e6e912325a5 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Tue, 13 Dec 2022 14:59:24 +0100 Subject: MDEV-30157: Galera SST doesn't properly handle undo* files from innodb This fix adds separate handling for "undo*" files that contain undo logs as part of innodb files and adds a filter for undo* to the main filter used when initially transferring files with rsync. --- scripts/wsrep_sst_rsync.sh | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index ee3e848025b..123b0ab04dc 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -549,7 +549,10 @@ FILTER="-f '- /lost+found' -f '+ /wsrep_sst_binlog.tar' -f '- $ib_home_dir/ib_lru_dump' -f '- $ib_home_dir/ibdata*' - -f '+ $ib_undo_dir/undo*' + -f '- $ib_undo_dir/undo*' + -f '- $ib_log_dir/ib_logfile[0-9]*' + -f '- $ib_log_dir/aria_log_control' + -f '- $ib_log_dir/aria_log.*' -f '+ /*/' -f '- /*'" @@ -610,24 +613,44 @@ FILTER="-f '- /lost+found' wsrep_log_info "Transfer of InnoDB and Aria log files done" + # third, we transfer InnoDB undo logs + rsync ${STUNNEL:+--rsh="$STUNNEL"} \ + --owner --group --perms --links --specials \ + --ignore-times --inplace --dirs --delete --quiet \ + $WHOLE_FILE_OPT -f '+ /undo*' \ + -f '- **' "$ib_undo_dir/" \ + "rsync://$WSREP_SST_OPT_ADDR-undo_dir" >&2 || RC=$? + + if [ $RC -ne 0 ]; then + wsrep_log_error "rsync innodb_undo_dir returned code $RC:" + exit 255 # unknown error + fi + + wsrep_log_info "Transfer of InnoDB undo logs done" + # then, we parallelize the transfer of database directories, # use '.' so that path concatenation works: - cd "$DATA" - backup_threads=$(parse_cnf '--mysqld|sst' 'backup-threads') if [ -z "$backup_threads" ]; then get_proc backup_threads=$nproc fi + cd "$DATA" + find . -maxdepth 1 -mindepth 1 -type d -not -name 'lost+found' \ -not -name '.zfs' -print0 | xargs -I{} -0 -P $backup_threads \ rsync ${STUNNEL:+--rsh="$STUNNEL"} \ --owner --group --perms --links --specials --ignore-times \ --inplace --recursive --delete --quiet $WHOLE_FILE_OPT \ - --exclude '*/ib_logfile*' --exclude '*/aria_log.*' \ - --exclude '*/aria_log_control' "$WSREP_SST_OPT_DATA/{}/" \ + -f '- $ib_home_dir/ib_lru_dump' \ + -f '- $ib_home_dir/ibdata*' \ + -f '- $ib_undo_dir/undo*' \ + -f '- $ib_log_dir/ib_logfile[0-9]*' \ + -f '- $ib_log_dir/aria_log_control' \ + -f '- $ib_log_dir/aria_log.*' \ + "$WSREP_SST_OPT_DATA/{}/" \ "rsync://$WSREP_SST_OPT_ADDR/{}" >&2 || RC=$? cd "$OLD_PWD" @@ -715,6 +738,8 @@ $SILENT path = $ib_log_dir [$MODULE-data_dir] path = $ib_home_dir +[$MODULE-undo_dir] + path = $ib_undo_dir EOF # If the IP is local, listen only on it: -- cgit v1.2.1 From 53c4be7bc02949e178b31fd89c4b196dd7f24bd0 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Tue, 13 Dec 2022 15:44:24 +0100 Subject: MDEV-30220: rsync SST completely ignores aria-log-dir-path This commit adds support for the --aria-log-dir-path option on the command line and for the aria-log-dir-path option in the configuration file to the SST scripts, since before this change these parameters were completely ignored during SST - SST scripts assumed that aria logs files are always located in the same directory as logs for innodb. Tests for this change will be added as a separate commit, along with tests for MDEV-30157 and MDEV-28669. --- scripts/wsrep_sst_common.sh | 19 +++++++++++++++ scripts/wsrep_sst_mariabackup.sh | 21 +++++++++++++++++ scripts/wsrep_sst_rsync.sh | 51 +++++++++++++++++++++++++++++++++------- 3 files changed, 83 insertions(+), 8 deletions(-) (limited to 'scripts') diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index 407a4c9dd24..4e177073872 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -134,6 +134,7 @@ WSREP_SST_OPT_ADDR="" WSREP_SST_OPT_ADDR_PORT="" WSREP_SST_OPT_HOST="" WSREP_SST_OPT_HOST_UNESCAPED="" +ARIA_LOG_DIR="" INNODB_DATA_HOME_DIR=$(trim_dir "${INNODB_DATA_HOME_DIR:-}") INNODB_LOG_GROUP_HOME=$(trim_dir "${INNODB_LOG_GROUP_HOME:-}") INNODB_UNDO_DIR=$(trim_dir "${INNODB_UNDO_DIR:-}") @@ -234,6 +235,11 @@ case "$1" in readonly WSREP_SST_OPT_DATA=$(trim_dir "$2") shift ;; + '--aria-log-dir-path') + # Let's remove the trailing slash: + readonly ARIA_LOG_DIR=$(trim_dir "$2") + shift + ;; '--innodb-data-home-dir') # Let's remove the trailing slash: readonly INNODB_DATA_HOME_DIR=$(trim_dir "$2") @@ -499,6 +505,12 @@ case "$1" in # from mysqld's argument list: skip_mysqld_arg=0 case "$option" in + '--aria-log-dir-path') + if [ -z "$ARIA_LOG_DIR" ]; then + MYSQLD_OPT_ARIA_LOG_DIR=$(trim_dir "$value") + fi + skip_mysqld_arg=1 + ;; '--innodb-data-home-dir') if [ -z "$INNODB_DATA_HOME_DIR" ]; then MYSQLD_OPT_INNODB_DATA_HOME_DIR=$(trim_dir "$value") @@ -592,6 +604,10 @@ readonly WSREP_SST_OPT_PROGRESS # The same argument can be present on the command line several # times, in this case we must take its last value: +if [ -n "${MYSQLD_OPT_ARIA_LOG_DIR:-}" -a \ + -z "$ARIA_LOG_DIR" ]; then + readonly ARIA_LOG_DIR="$MYSQLD_OPT_ARIA_LOG_DIR" +fi if [ -n "${MYSQLD_OPT_INNODB_DATA_HOME_DIR:-}" -a \ -z "$INNODB_DATA_HOME_DIR" ]; then readonly INNODB_DATA_HOME_DIR="$MYSQLD_OPT_INNODB_DATA_HOME_DIR" @@ -649,6 +665,9 @@ if [ -n "$WSREP_SST_OPT_LOG_BASENAME" ]; then WSREP_SST_OPT_MYSQLD="--log-basename='$WSREP_SST_OPT_LOG_BASENAME'" fi fi +if [ -n "$ARIA_LOG_DIR" ]; then + INNOEXTRA="$INNOEXTRA --aria-log-dir-path='$ARIA_LOG_DIR'" +fi if [ -n "$INNODB_DATA_HOME_DIR" ]; then INNOEXTRA="$INNOEXTRA --innodb-data-home-dir='$INNODB_DATA_HOME_DIR'" fi diff --git a/scripts/wsrep_sst_mariabackup.sh b/scripts/wsrep_sst_mariabackup.sh index 7465b2a3b08..7e26af83701 100644 --- a/scripts/wsrep_sst_mariabackup.sh +++ b/scripts/wsrep_sst_mariabackup.sh @@ -55,6 +55,7 @@ speciald=1 ib_home_dir="" ib_log_dir="" ib_undo_dir="" +ar_log_dir="" sfmt="" strmcmd="" @@ -1271,6 +1272,24 @@ else # joiner [ "$ib_undo_dir" = "$DATA_DIR" ] && ib_undo_dir="" fi + # if no command line argument then try to get it from the my.cnf: + if [ -z "$ARIA_LOG_DIR" ]; then + ARIA_LOG_DIR=$(parse_cnf '--mysqld' 'aria-log-dir-path') + ARIA_LOG_DIR=$(trim_dir "$ARIA_LOG_DIR") + fi + + if [ -n "$ARIA_LOG_DIR" -a "$ARIA_LOG_DIR" != '.' -a \ + "$ARIA_LOG_DIR" != "$DATA_DIR" ] + then + # handle both relative and absolute paths: + cd "$DATA" + [ ! -d "$ARIA_LOG_DIR" ] && mkdir -p "$ARIA_LOG_DIR" + cd "$ARIA_LOG_DIR" + ar_log_dir="$(pwd)" + cd "$OLD_PWD" + [ "$ar_log_dir" = "$DATA_DIR" ] && ar_log_dir="" + fi + if [ -n "$backup_threads" ]; then impts="--parallel=$backup_threads${impts:+ }$impts" fi @@ -1410,12 +1429,14 @@ else # joiner find -E ${ib_home_dir:+"$ib_home_dir"} \ ${ib_undo_dir:+"$ib_undo_dir"} \ ${ib_log_dir:+"$ib_log_dir"} \ + ${ar_log_dir:+"$ar_log_dir"} \ "$DATA" -mindepth 1 -prune -regex "$cpat" \ -o -exec rm -rf {} >&2 \+ else find ${ib_home_dir:+"$ib_home_dir"} \ ${ib_undo_dir:+"$ib_undo_dir"} \ ${ib_log_dir:+"$ib_log_dir"} \ + ${ar_log_dir:+"$ar_log_dir"} \ "$DATA" -mindepth 1 -prune -regex "$cpat" \ -o -exec rm -rf {} >&2 \+ fi diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index 123b0ab04dc..5279929c5b0 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -174,6 +174,7 @@ cd "$OLD_PWD" BINLOG_TAR_FILE="$DATA_DIR/wsrep_sst_binlog.tar" +ar_log_dir="$DATA_DIR" ib_log_dir="$DATA_DIR" ib_home_dir="$DATA_DIR" ib_undo_dir="$DATA_DIR" @@ -232,6 +233,23 @@ then cd "$OLD_PWD" fi +# if no command line argument then try to get it from the my.cnf: +if [ -z "$ARIA_LOG_DIR" ]; then + ARIA_LOG_DIR=$(parse_cnf '--mysqld' 'aria-log-dir-path') + ARIA_LOG_DIR=$(trim_dir "$ARIA_LOG_DIR") +fi + +if [ -n "$ARIA_LOG_DIR" -a "$ARIA_LOG_DIR" != '.' -a \ + "$ARIA_LOG_DIR" != "$DATA_DIR" ] +then + # handle both relative and absolute paths: + cd "$DATA" + [ ! -d "$ARIA_LOG_DIR" ] && mkdir -p "$ARIA_LOG_DIR" + cd "$ARIA_LOG_DIR" + ar_log_dir="$(pwd)" + cd "$OLD_PWD" +fi + encgroups='--mysqld|sst' check_server_ssl_config @@ -551,8 +569,8 @@ FILTER="-f '- /lost+found' -f '- $ib_home_dir/ibdata*' -f '- $ib_undo_dir/undo*' -f '- $ib_log_dir/ib_logfile[0-9]*' - -f '- $ib_log_dir/aria_log_control' - -f '- $ib_log_dir/aria_log.*' + -f '- $ar_log_dir/aria_log_control' + -f '- $ar_log_dir/aria_log.*' -f '+ /*/' -f '- /*'" @@ -598,12 +616,12 @@ FILTER="-f '- /lost+found' wsrep_log_info "Transfer of InnoDB data files done" - # second, we transfer InnoDB and Aria log files + # second, we transfer InnoDB log files rsync ${STUNNEL:+--rsh="$STUNNEL"} \ --owner --group --perms --links --specials \ --ignore-times --inplace --dirs --delete --quiet \ - $WHOLE_FILE_OPT -f '+ /ib_logfile[0-9]*' -f '+ /aria_log.*' \ - -f '+ /aria_log_control' -f '- **' "$ib_log_dir/" \ + $WHOLE_FILE_OPT -f '+ /ib_logfile[0-9]*' \ + -f '- **' "$ib_log_dir/" \ "rsync://$WSREP_SST_OPT_ADDR-log_dir" >&2 || RC=$? if [ $RC -ne 0 ]; then @@ -611,7 +629,7 @@ FILTER="-f '- /lost+found' exit 255 # unknown error fi - wsrep_log_info "Transfer of InnoDB and Aria log files done" + wsrep_log_info "Transfer of InnoDB log files done" # third, we transfer InnoDB undo logs rsync ${STUNNEL:+--rsh="$STUNNEL"} \ @@ -628,6 +646,21 @@ FILTER="-f '- /lost+found' wsrep_log_info "Transfer of InnoDB undo logs done" + # fourth, we transfer Aria logs + rsync ${STUNNEL:+--rsh="$STUNNEL"} \ + --owner --group --perms --links --specials \ + --ignore-times --inplace --dirs --delete --quiet \ + $WHOLE_FILE_OPT -f '+ /aria_log_control' -f '+ /aria_log.*' \ + -f '- **' "$ar_log_dir/" \ + "rsync://$WSREP_SST_OPT_ADDR-aria_log" >&2 || RC=$? + + if [ $RC -ne 0 ]; then + wsrep_log_error "rsync aria_log_dir_path returned code $RC:" + exit 255 # unknown error + fi + + wsrep_log_info "Transfer of Aria logs done" + # then, we parallelize the transfer of database directories, # use '.' so that path concatenation works: @@ -648,8 +681,8 @@ FILTER="-f '- /lost+found' -f '- $ib_home_dir/ibdata*' \ -f '- $ib_undo_dir/undo*' \ -f '- $ib_log_dir/ib_logfile[0-9]*' \ - -f '- $ib_log_dir/aria_log_control' \ - -f '- $ib_log_dir/aria_log.*' \ + -f '- $ar_log_dir/aria_log_control' \ + -f '- $ar_log_dir/aria_log.*' \ "$WSREP_SST_OPT_DATA/{}/" \ "rsync://$WSREP_SST_OPT_ADDR/{}" >&2 || RC=$? @@ -740,6 +773,8 @@ $SILENT path = $ib_home_dir [$MODULE-undo_dir] path = $ib_undo_dir +[$MODULE-aria_log] + path = $ar_log_dir EOF # If the IP is local, listen only on it: -- cgit v1.2.1 From eb145e5ad7afa29f1d298452b80fcca36a6c3bbe Mon Sep 17 00:00:00 2001 From: lilinjie Date: Thu, 12 Jan 2023 10:38:38 +0800 Subject: fix typos Signed-off-by: lilinjie --- scripts/mysqlaccess.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/mysqlaccess.sh b/scripts/mysqlaccess.sh index aaf711b0fb9..83118a8fdc6 100644 --- a/scripts/mysqlaccess.sh +++ b/scripts/mysqlaccess.sh @@ -584,7 +584,7 @@ if ($MySQLaccess::CGI) { #CGI-version # ---------------------- # brief and table-format # exclude each-other -# table-format is prefered +# table-format is preferred if (defined($Param{'table'})) { undef($Param{'brief'}); } if (defined($Param{'preview'}) or defined($Param{'copy'}) or -- cgit v1.2.1