Commit e0324bf3 authored by Julius Goryavsky's avatar Julius Goryavsky

wsrep sst scripts: removing extra blank lines and spaces

Removed numerous extra blank lines and spaces that interfere with
reading and understanding program code, making it more difficult to
find errors in scripts. I also removed all extra trailing spaces at
the ends of lines, which lead to marking extra lines as changes
(in subsequent changes). The amount of indentation in some parts
of the code has also been normalized.
parent 562c8825
...@@ -194,9 +194,9 @@ case "$1" in ...@@ -194,9 +194,9 @@ case "$1" in
shift shift
;; ;;
'--binlog-index') '--binlog-index')
WSREP_SST_OPT_BINLOG_INDEX="$2" WSREP_SST_OPT_BINLOG_INDEX="$2"
shift shift
;; ;;
'--gtid-domain-id') '--gtid-domain-id')
readonly WSREP_SST_OPT_GTID_DOMAIN_ID="$2" readonly WSREP_SST_OPT_GTID_DOMAIN_ID="$2"
shift shift
...@@ -298,11 +298,11 @@ fi ...@@ -298,11 +298,11 @@ fi
wsrep_defaults="$WSREP_SST_OPT_DEFAULT" wsrep_defaults="$WSREP_SST_OPT_DEFAULT"
if [ -n "$wsrep_defaults" ]; then if [ -n "$wsrep_defaults" ]; then
wsrep_defaults="$wsrep_defaults " wsrep_defaults="$wsrep_defaults "
fi fi
wsrep_defaults="$wsrep_defaults$WSREP_SST_OPT_EXTRA_DEFAULT" wsrep_defaults="$wsrep_defaults$WSREP_SST_OPT_EXTRA_DEFAULT"
if [ -n "$wsrep_defaults" ]; then if [ -n "$wsrep_defaults" ]; then
wsrep_defaults="$wsrep_defaults " wsrep_defaults="$wsrep_defaults "
fi fi
readonly WSREP_SST_OPT_CONF="$wsrep_defaults$WSREP_SST_OPT_SUFFIX_DEFAULT" readonly WSREP_SST_OPT_CONF="$wsrep_defaults$WSREP_SST_OPT_SUFFIX_DEFAULT"
readonly MY_PRINT_DEFAULTS="$MY_PRINT_DEFAULTS $WSREP_SST_OPT_CONF" readonly MY_PRINT_DEFAULTS="$MY_PRINT_DEFAULTS $WSREP_SST_OPT_CONF"
......
...@@ -87,8 +87,8 @@ set +e ...@@ -87,8 +87,8 @@ set +e
INNOBACKUPEX_BIN=$(which mariabackup) INNOBACKUPEX_BIN=$(which mariabackup)
if test -z $INNOBACKUPEX_BIN if test -z $INNOBACKUPEX_BIN
then then
wsrep_log_error 'mariabackup binary not found in $PATH' wsrep_log_error 'mariabackup binary not found in $PATH'
exit 42 exit 42
fi fi
set -e set -e
XBSTREAM_BIN=mbstream XBSTREAM_BIN=mbstream
...@@ -111,7 +111,7 @@ timeit(){ ...@@ -111,7 +111,7 @@ timeit(){
local cmd="$@" local cmd="$@"
local x1 x2 took extcode local x1 x2 took extcode
if [[ $ttime -eq 1 ]];then if [[ $ttime -eq 1 ]];then
x1=$(date +%s) x1=$(date +%s)
wsrep_log_info "Evaluating $cmd" wsrep_log_info "Evaluating $cmd"
eval "$cmd" eval "$cmd"
...@@ -120,7 +120,7 @@ timeit(){ ...@@ -120,7 +120,7 @@ timeit(){
took=$(( x2-x1 )) took=$(( x2-x1 ))
wsrep_log_info "NOTE: $stage took $took seconds" wsrep_log_info "NOTE: $stage took $took seconds"
totime=$(( totime+took )) totime=$(( totime+took ))
else else
wsrep_log_info "Evaluating $cmd" wsrep_log_info "Evaluating $cmd"
eval "$cmd" eval "$cmd"
extcode=$? extcode=$?
...@@ -131,11 +131,11 @@ timeit(){ ...@@ -131,11 +131,11 @@ timeit(){
get_keys() get_keys()
{ {
# $encrypt -eq 1 is for internal purposes only # $encrypt -eq 1 is for internal purposes only
if [[ $encrypt -ge 2 || $encrypt -eq -1 ]];then if [[ $encrypt -ge 2 || $encrypt -eq -1 ]];then
return return
fi fi
if [[ $encrypt -eq 0 ]];then if [[ $encrypt -eq 0 ]];then
if $MY_PRINT_DEFAULTS xtrabackup | grep -q encrypt;then if $MY_PRINT_DEFAULTS xtrabackup | grep -q encrypt;then
wsrep_log_error "Unexpected option combination. SST may fail. Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html" wsrep_log_error "Unexpected option combination. SST may fail. Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html"
fi fi
...@@ -175,18 +175,18 @@ get_keys() ...@@ -175,18 +175,18 @@ get_keys()
get_transfer() get_transfer()
{ {
if [[ -z $SST_PORT ]];then if [[ -z $SST_PORT ]];then
TSST_PORT=4444 TSST_PORT=4444
else else
TSST_PORT=$SST_PORT TSST_PORT=$SST_PORT
fi fi
if [[ $tfmt == 'nc' ]];then if [[ $tfmt == 'nc' ]];then
wsrep_check_programs nc wsrep_check_programs nc
wsrep_log_info "Using netcat as streamer" wsrep_log_info "Using netcat as streamer"
if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
if nc -h 2>&1 | grep -q ncat;then if nc -h 2>&1 | grep -q ncat;then
# Ncat # Ncat
tcmd="nc -l ${TSST_PORT}" tcmd="nc -l ${TSST_PORT}"
elif nc -h 2>&1 | grep -qw -- '-d\>';then elif nc -h 2>&1 | grep -qw -- '-d\>';then
...@@ -215,9 +215,8 @@ get_transfer() ...@@ -215,9 +215,8 @@ get_transfer()
tcmd_extra="" tcmd_extra=""
if nc -h 2>&1 | grep -qw -- -N; then if nc -h 2>&1 | grep -qw -- -N; then
tcmd_extra+="-N" tcmd_extra+="-N"
wsrep_log_info "Using nc -N" wsrep_log_info "Using nc -N"
fi fi
# netcat doesn't understand [] around IPv6 address # netcat doesn't understand [] around IPv6 address
if nc -h 2>&1 | grep -q ncat;then if nc -h 2>&1 | grep -q ncat;then
# Ncat # Ncat
...@@ -235,7 +234,7 @@ get_transfer() ...@@ -235,7 +234,7 @@ get_transfer()
fi fi
else else
tfmt='socat' tfmt='socat'
wsrep_check_programs socat wsrep_check_programs socat
wsrep_log_info "Using socat as streamer" wsrep_log_info "Using socat as streamer"
if [[ $encrypt -eq 2 || $encrypt -eq 3 ]] && ! socat -V | grep -q "WITH_OPENSSL 1";then if [[ $encrypt -eq 2 || $encrypt -eq 3 ]] && ! socat -V | grep -q "WITH_OPENSSL 1";then
...@@ -243,9 +242,9 @@ get_transfer() ...@@ -243,9 +242,9 @@ get_transfer()
exit 2 exit 2
fi fi
if [[ $encrypt -eq 2 ]];then if [[ $encrypt -eq 2 ]];then
wsrep_log_info "Using openssl based encryption with socat: with crt and pem" wsrep_log_info "Using openssl based encryption with socat: with crt and pem"
if [[ -z $tpem || -z $tcert ]];then if [[ -z $tpem || -z $tcert ]];then
wsrep_log_error "Both PEM and CRT files required" wsrep_log_error "Both PEM and CRT files required"
exit 22 exit 22
fi fi
...@@ -281,8 +280,7 @@ get_transfer() ...@@ -281,8 +280,7 @@ get_transfer()
tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${tpem},key=${tkey},cafile=${tcert}${sockopt}" tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${tpem},key=${tkey},cafile=${tcert}${sockopt}"
fi fi
fi fi
else
else
if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
tcmd="socat -u TCP-LISTEN:${TSST_PORT},reuseaddr${sockopt} stdio" tcmd="socat -u TCP-LISTEN:${TSST_PORT},reuseaddr${sockopt} stdio"
else else
...@@ -290,7 +288,6 @@ get_transfer() ...@@ -290,7 +288,6 @@ get_transfer()
fi fi
fi fi
fi fi
} }
parse_cnf() parse_cnf()
...@@ -302,7 +299,7 @@ parse_cnf() ...@@ -302,7 +299,7 @@ parse_cnf()
# then grep for needed variable # then grep for needed variable
# finally get the variable value (if variables has been specified multiple time use the last value only) # finally get the variable value (if variables has been specified multiple time use the last value only)
reval=$($MY_PRINT_DEFAULTS $group | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2- | tail -1) reval=$($MY_PRINT_DEFAULTS $group | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2- | tail -1)
if [[ -z $reval ]];then if [[ -z $reval ]];then
[[ -n $3 ]] && reval=$3 [[ -n $3 ]] && reval=$3
fi fi
echo $reval echo $reval
...@@ -312,7 +309,7 @@ get_footprint() ...@@ -312,7 +309,7 @@ get_footprint()
{ {
pushd $WSREP_SST_OPT_DATA 1>/dev/null pushd $WSREP_SST_OPT_DATA 1>/dev/null
payload=$(find . -regex '.*\.ibd$\|.*\.MYI$\|.*\.MYD$\|.*ibdata1$' -type f -print0 | du --files0-from=- --block-size=1 -c | awk 'END { print $1 }') payload=$(find . -regex '.*\.ibd$\|.*\.MYI$\|.*\.MYD$\|.*ibdata1$' -type f -print0 | du --files0-from=- --block-size=1 -c | awk 'END { print $1 }')
if $MY_PRINT_DEFAULTS xtrabackup | grep -q -- "--compress";then if $MY_PRINT_DEFAULTS xtrabackup | grep -q -- "--compress";then
# QuickLZ has around 50% compression ratio # QuickLZ has around 50% compression ratio
# When compression/compaction used, the progress is only an approximate. # When compression/compaction used, the progress is only an approximate.
payload=$(( payload*1/2 )) payload=$(( payload*1/2 ))
...@@ -324,7 +321,6 @@ get_footprint() ...@@ -324,7 +321,6 @@ get_footprint()
adjust_progress() adjust_progress()
{ {
if ! command -v pv >/dev/null;then if ! command -v pv >/dev/null;then
wsrep_log_error "pv not found in path: $PATH" wsrep_log_error "pv not found in path: $PATH"
wsrep_log_error "Disabling all progress/rate-limiting" wsrep_log_error "Disabling all progress/rate-limiting"
...@@ -334,16 +330,16 @@ adjust_progress() ...@@ -334,16 +330,16 @@ adjust_progress()
return return
fi fi
if [[ -n $progress && $progress != '1' ]];then if [[ -n $progress && $progress != '1' ]];then
if [[ -e $progress ]];then if [[ -e $progress ]];then
pcmd+=" 2>>$progress" pcmd+=" 2>>$progress"
else else
pcmd+=" 2>$progress" pcmd+=" 2>$progress"
fi fi
elif [[ -z $progress && -n $rlimit ]];then elif [[ -z $progress && -n $rlimit ]];then
# When rlimit is non-zero # When rlimit is non-zero
pcmd="pv -q" pcmd="pv -q"
fi fi
if [[ -n $rlimit && "$WSREP_SST_OPT_ROLE" == "donor" ]];then if [[ -n $rlimit && "$WSREP_SST_OPT_ROLE" == "donor" ]];then
wsrep_log_info "Rate-limiting SST to $rlimit" wsrep_log_info "Rate-limiting SST to $rlimit"
...@@ -371,7 +367,7 @@ read_cnf() ...@@ -371,7 +367,7 @@ read_cnf()
scomp=$(parse_cnf sst compressor "") scomp=$(parse_cnf sst compressor "")
sdecomp=$(parse_cnf sst decompressor "") sdecomp=$(parse_cnf sst decompressor "")
# Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html # Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html
if [[ -z $ealgo ]];then if [[ -z $ealgo ]];then
ealgo=$(parse_cnf sst encrypt-algo "") ealgo=$(parse_cnf sst encrypt-algo "")
ekey=$(parse_cnf sst encrypt-key "") ekey=$(parse_cnf sst encrypt-key "")
...@@ -391,13 +387,13 @@ read_cnf() ...@@ -391,13 +387,13 @@ read_cnf()
sstlogarchive=$(parse_cnf sst sst-log-archive 1) sstlogarchive=$(parse_cnf sst sst-log-archive 1)
sstlogarchivedir=$(parse_cnf sst sst-log-archive-dir "/tmp/sst_log_archive") sstlogarchivedir=$(parse_cnf sst sst-log-archive-dir "/tmp/sst_log_archive")
if [[ $speciald -eq 0 ]];then if [[ $speciald -eq 0 ]];then
wsrep_log_error "sst-special-dirs equal to 0 is not supported, falling back to 1" wsrep_log_error "sst-special-dirs equal to 0 is not supported, falling back to 1"
speciald=1 speciald=1
fi fi
if [[ $ssyslog -ne -1 ]];then if [[ $ssyslog -ne -1 ]];then
if $MY_PRINT_DEFAULTS mysqld_safe | tr '_' '-' | grep -q -- "--syslog";then if $MY_PRINT_DEFAULTS mysqld_safe | tr '_' '-' | grep -q -- "--syslog";then
ssyslog=1 ssyslog=1
fi fi
fi fi
...@@ -426,7 +422,6 @@ get_stream() ...@@ -426,7 +422,6 @@ get_stream()
else else
strmcmd="tar cf - \${INFO_FILE} " strmcmd="tar cf - \${INFO_FILE} "
fi fi
fi fi
} }
...@@ -448,33 +443,32 @@ cleanup_joiner() ...@@ -448,33 +443,32 @@ cleanup_joiner()
{ {
# Since this is invoked just after exit NNN # Since this is invoked just after exit NNN
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 [ "${WSREP_SST_OPT_ROLE}" = "joiner" ];then elif [ "${WSREP_SST_OPT_ROLE}" = "joiner" ];then
wsrep_log_info "Removing the sst_in_progress file" wsrep_log_info "Removing the sst_in_progress file"
wsrep_cleanup_progress_file wsrep_cleanup_progress_file
fi fi
if [[ -n $progress && -p $progress ]];then if [[ -n $progress && -p $progress ]];then
wsrep_log_info "Cleaning up fifo file $progress" wsrep_log_info "Cleaning up fifo file $progress"
rm $progress rm $progress
fi fi
if [[ -n ${STATDIR:-} ]];then
if [[ -n ${STATDIR:-} ]];then
[[ -d $STATDIR ]] && rm -rf $STATDIR [[ -d $STATDIR ]] && rm -rf $STATDIR
fi fi
# Final cleanup # Final cleanup
pgid=$(ps -o pgid= $$ | grep -o '[0-9]*') pgid=$(ps -o pgid= $$ | grep -o '[0-9]*')
# This means no setsid done in mysqld. # This means no setsid done in mysqld.
# We don't want to kill mysqld here otherwise. # We don't want to kill mysqld here otherwise.
if [[ $$ -eq $pgid ]];then if [[ $$ -eq $pgid ]];then
# This means a signal was delivered to the process. # This means a signal was delivered to the process.
# So, more cleanup. # So, more cleanup.
if [[ $estatus -ge 128 ]];then if [[ $estatus -ge 128 ]];then
kill -KILL -$$ || true kill -KILL -$$ || true
fi fi
fi fi
exit $estatus exit $estatus
...@@ -490,52 +484,49 @@ cleanup_donor() ...@@ -490,52 +484,49 @@ cleanup_donor()
{ {
# Since this is invoked just after exit NNN # Since this is invoked just after exit NNN
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"
fi fi
if [[ -n ${XTRABACKUP_PID:-} ]];then if [[ -n ${XTRABACKUP_PID:-} ]];then
if check_pid $XTRABACKUP_PID if check_pid $XTRABACKUP_PID
then then
wsrep_log_error "xtrabackup process is still running. Killing..." wsrep_log_error "xtrabackup process is still running. Killing..."
kill_xtrabackup kill_xtrabackup
fi fi
fi fi
rm -f ${DATA}/${IST_FILE} || true rm -f ${DATA}/${IST_FILE} || true
if [[ -n $progress && -p $progress ]];then if [[ -n $progress && -p $progress ]];then
wsrep_log_info "Cleaning up fifo file $progress" wsrep_log_info "Cleaning up fifo file $progress"
rm -f $progress || true rm -f $progress || true
fi fi
wsrep_log_info "Cleaning up temporary directories" wsrep_log_info "Cleaning up temporary directories"
if [[ -n $xtmpdir ]];then if [[ -n $xtmpdir ]];then
[[ -d $xtmpdir ]] && rm -rf $xtmpdir || true [[ -d $xtmpdir ]] && rm -rf $xtmpdir || true
fi fi
if [[ -n $itmpdir ]];then if [[ -n $itmpdir ]];then
[[ -d $itmpdir ]] && rm -rf $itmpdir || true [[ -d $itmpdir ]] && rm -rf $itmpdir || true
fi fi
# Final cleanup # Final cleanup
pgid=$(ps -o pgid= $$ | grep -o '[0-9]*') pgid=$(ps -o pgid= $$ | grep -o '[0-9]*')
# This means no setsid done in mysqld. # This means no setsid done in mysqld.
# We don't want to kill mysqld here otherwise. # We don't want to kill mysqld here otherwise.
if [[ $$ -eq $pgid ]];then if [[ $$ -eq $pgid ]];then
# This means a signal was delivered to the process. # This means a signal was delivered to the process.
# So, more cleanup. # So, more cleanup.
if [[ $estatus -ge 128 ]];then if [[ $estatus -ge 128 ]];then
kill -KILL -$$ || true kill -KILL -$$ || true
fi fi
fi fi
exit $estatus exit $estatus
} }
kill_xtrabackup() kill_xtrabackup()
...@@ -565,7 +556,7 @@ wait_for_listen() ...@@ -565,7 +556,7 @@ wait_for_listen()
local MODULE=$3 local MODULE=$3
for i in {1..50} for i in {1..50}
do do
if [ "$OS" = "FreeBSD" ];then if [ "$OS" = "FreeBSD" ];then
sockstat -46lp $PORT | grep -qE "^[^ ]* *(socat|nc) *[^ ]* *[^ ]* *[^ ]* *[^ ]*:$PORT" && break sockstat -46lp $PORT | grep -qE "^[^ ]* *(socat|nc) *[^ ]* *[^ ]* *[^ ]* *[^ ]*:$PORT" && break
else else
ss -p state listening "( sport = :$PORT )" | grep -qE 'socat|nc' && break ss -p state listening "( sport = :$PORT )" | grep -qE 'socat|nc' && break
...@@ -578,20 +569,20 @@ wait_for_listen() ...@@ -578,20 +569,20 @@ wait_for_listen()
check_extra() check_extra()
{ {
local use_socket=1 local use_socket=1
if [[ $uextra -eq 1 ]];then if [[ $uextra -eq 1 ]];then
if $MY_PRINT_DEFAULTS --mysqld | tr '_' '-' | grep -- "--thread-handling=" | grep -q 'pool-of-threads';then if $MY_PRINT_DEFAULTS --mysqld | tr '_' '-' | grep -- "--thread-handling=" | grep -q 'pool-of-threads';then
local eport=$($MY_PRINT_DEFAULTS --mysqld | tr '_' '-' | grep -- "--extra-port=" | cut -d= -f2) local eport=$($MY_PRINT_DEFAULTS --mysqld | tr '_' '-' | grep -- "--extra-port=" | cut -d= -f2)
if [[ -n $eport ]];then if [[ -n $eport ]];then
# Xtrabackup works only locally. # Xtrabackup works only locally.
# Hence, setting host to 127.0.0.1 unconditionally. # Hence, setting host to 127.0.0.1 unconditionally.
wsrep_log_info "SST through extra_port $eport" wsrep_log_info "SST through extra_port $eport"
INNOEXTRA+=" --host=127.0.0.1 --port=$eport" INNOEXTRA+=" --host=127.0.0.1 --port=$eport"
use_socket=0 use_socket=0
else else
wsrep_log_error "Extra port $eport null, failing" wsrep_log_error "Extra port $eport null, failing"
exit 1 exit 1
fi fi
else else
wsrep_log_info "Thread pool not set, ignore the option use_extra" wsrep_log_info "Thread pool not set, ignore the option use_extra"
fi fi
fi fi
...@@ -603,7 +594,7 @@ check_extra() ...@@ -603,7 +594,7 @@ check_extra()
recv_joiner() recv_joiner()
{ {
local dir=$1 local dir=$1
local msg=$2 local msg=$2
local tmt=$3 local tmt=$3
local checkf=$4 local checkf=$4
local ltcmd local ltcmd
...@@ -617,27 +608,27 @@ recv_joiner() ...@@ -617,27 +608,27 @@ recv_joiner()
set +e set +e
if [[ $tmt -gt 0 ]] && command -v timeout >/dev/null;then if [[ $tmt -gt 0 ]] && command -v timeout >/dev/null;then
if timeout --help | grep -q -- '-k';then if timeout --help | grep -q -- '-k';then
ltcmd="timeout -k $(( tmt+10 )) $tmt $tcmd" ltcmd="timeout -k $(( tmt+10 )) $tmt $tcmd"
else else
ltcmd="timeout -s9 $tmt $tcmd" ltcmd="timeout -s9 $tmt $tcmd"
fi fi
timeit "$msg" "$ltcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )" timeit "$msg" "$ltcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
else else
timeit "$msg" "$tcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )" timeit "$msg" "$tcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
fi fi
set -e set -e
popd 1>/dev/null popd 1>/dev/null
if [[ ${RC[0]} -eq 124 ]];then if [[ ${RC[0]} -eq 124 ]];then
wsrep_log_error "Possible timeout in receiving first data from " wsrep_log_error "Possible timeout in receiving first data from "
"donor in gtid stage: exit codes: ${RC[@]}" "donor in gtid stage: exit codes: ${RC[@]}"
exit 32 exit 32
fi fi
for ecode in "${RC[@]}";do for ecode in "${RC[@]}";do
if [[ $ecode -ne 0 ]];then if [[ $ecode -ne 0 ]];then
wsrep_log_error "Error while getting data from donor node: " \ wsrep_log_error "Error while getting data from donor node: " \
"exit codes: ${RC[@]}" "exit codes: ${RC[@]}"
exit 32 exit 32
...@@ -647,33 +638,30 @@ recv_joiner() ...@@ -647,33 +638,30 @@ recv_joiner()
if [[ $checkf -eq 1 && ! -r "${MAGIC_FILE}" ]];then if [[ $checkf -eq 1 && ! -r "${MAGIC_FILE}" ]];then
# this message should cause joiner to abort # this message should cause joiner to abort
wsrep_log_error "xtrabackup process ended without creating '${MAGIC_FILE}'" wsrep_log_error "xtrabackup process ended without creating '${MAGIC_FILE}'"
wsrep_log_info "Contents of datadir" wsrep_log_info "Contents of datadir"
wsrep_log_info "$(ls -l ${dir}/*)" wsrep_log_info "$(ls -l ${dir}/*)"
exit 32 exit 32
fi fi
} }
send_donor() send_donor()
{ {
local dir=$1 local dir=$1
local msg=$2 local msg=$2
pushd ${dir} 1>/dev/null pushd ${dir} 1>/dev/null
set +e set +e
timeit "$msg" "$strmcmd | $tcmd; RC=( "\${PIPESTATUS[@]}" )" timeit "$msg" "$strmcmd | $tcmd; RC=( "\${PIPESTATUS[@]}" )"
set -e set -e
popd 1>/dev/null popd 1>/dev/null
for ecode in "${RC[@]}";do for ecode in "${RC[@]}";do
if [[ $ecode -ne 0 ]];then if [[ $ecode -ne 0 ]];then
wsrep_log_error "Error while getting data from donor node: " \ wsrep_log_error "Error while getting data from donor node: " \
"exit codes: ${RC[@]}" "exit codes: ${RC[@]}"
exit 32 exit 32
fi fi
done done
} }
monitor_process() monitor_process()
...@@ -681,18 +669,14 @@ monitor_process() ...@@ -681,18 +669,14 @@ monitor_process()
local sst_stream_pid=$1 local sst_stream_pid=$1
while true ; do while true ; do
if ! ps -p "${WSREP_SST_OPT_PARENT}" &>/dev/null; then if ! ps -p "${WSREP_SST_OPT_PARENT}" &>/dev/null; then
wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly." wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly."
exit 32 exit 32
fi fi
if ! ps -p "${sst_stream_pid}" &>/dev/null; then if ! ps -p "${sst_stream_pid}" &>/dev/null; then
break break
fi fi
sleep 0.1 sleep 0.1
done done
} }
...@@ -700,7 +684,7 @@ wsrep_check_programs "$INNOBACKUPEX_BIN" ...@@ -700,7 +684,7 @@ wsrep_check_programs "$INNOBACKUPEX_BIN"
rm -f "${MAGIC_FILE}" rm -f "${MAGIC_FILE}"
if [[ ! ${WSREP_SST_OPT_ROLE} == 'joiner' && ! ${WSREP_SST_OPT_ROLE} == 'donor' ]];then if [[ ! ${WSREP_SST_OPT_ROLE} == 'joiner' && ! ${WSREP_SST_OPT_ROLE} == 'donor' ]];then
wsrep_log_error "Invalid role ${WSREP_SST_OPT_ROLE}" wsrep_log_error "Invalid role ${WSREP_SST_OPT_ROLE}"
exit 22 exit 22
fi fi
...@@ -708,13 +692,13 @@ fi ...@@ -708,13 +692,13 @@ fi
read_cnf read_cnf
setup_ports setup_ports
if ${INNOBACKUPEX_BIN} /tmp --help 2>/dev/null | grep -q -- '--version-check'; then if ${INNOBACKUPEX_BIN} /tmp --help 2>/dev/null | grep -q -- '--version-check'; then
disver="--no-version-check" disver="--no-version-check"
fi fi
iopts+=" --databases-exclude=\"lost+found\"" iopts+=" --databases-exclude=\"lost+found\""
if [[ ${FORCE_FTWRL:-0} -eq 1 ]];then if [[ ${FORCE_FTWRL:-0} -eq 1 ]];then
wsrep_log_info "Forcing FTWRL due to environment variable FORCE_FTWRL equal to $FORCE_FTWRL" wsrep_log_info "Forcing FTWRL due to environment variable FORCE_FTWRL equal to $FORCE_FTWRL"
iopts+=" --no-backup-locks" iopts+=" --no-backup-locks"
fi fi
...@@ -746,24 +730,23 @@ else ...@@ -746,24 +730,23 @@ else
INNODB_DATA_HOME_DIR=$(cd $DATA; pwd -P) INNODB_DATA_HOME_DIR=$(cd $DATA; pwd -P)
fi fi
if [[ $ssyslog -eq 1 ]];then if [[ $ssyslog -eq 1 ]];then
if ! command -v logger >/dev/null;then if ! command -v logger >/dev/null;then
wsrep_log_error "logger not in path: $PATH. Ignoring" wsrep_log_error "logger not in path: $PATH. Ignoring"
else else
wsrep_log_info "Logging all stderr of SST/Innobackupex to syslog" wsrep_log_info "Logging all stderr of SST/Innobackupex to syslog"
exec 2> >(logger -p daemon.err -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE) exec 2> >(logger -p daemon.err -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE)
wsrep_log_error() wsrep_log_error()
{ {
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_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 "$@"
} }
INNOAPPLY="${INNOBACKUPEX_BIN} --prepare $disver $iapts \$INNOEXTRA $rebuildcmd --target-dir=\${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-apply" INNOAPPLY="${INNOBACKUPEX_BIN} --prepare $disver $iapts \$INNOEXTRA $rebuildcmd --target-dir=\${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-apply"
...@@ -794,7 +777,6 @@ then ...@@ -794,7 +777,6 @@ then
else else
newfile=${INNOAPPLYLOG}.${ARCHIVETIMESTAMP} newfile=${INNOAPPLYLOG}.${ARCHIVETIMESTAMP}
fi fi
wsrep_log_info "Moving ${INNOAPPLYLOG} to ${newfile}" wsrep_log_info "Moving ${INNOAPPLYLOG} to ${newfile}"
mv "${INNOAPPLYLOG}" "${newfile}" mv "${INNOAPPLYLOG}" "${newfile}"
gzip "${newfile}" gzip "${newfile}"
...@@ -827,12 +809,12 @@ then ...@@ -827,12 +809,12 @@ then
mv "${INNOBACKUPLOG}" "${newfile}" mv "${INNOBACKUPLOG}" "${newfile}"
gzip "${newfile}" gzip "${newfile}"
fi fi
fi fi
INNOAPPLY="${INNOBACKUPEX_BIN} --prepare $disver $iapts \$INNOEXTRA $rebuildcmd --target-dir=\${DATA} &> ${INNOAPPLYLOG}" INNOAPPLY="${INNOBACKUPEX_BIN} --prepare $disver $iapts \$INNOEXTRA $rebuildcmd --target-dir=\${DATA} &> ${INNOAPPLYLOG}"
INNOMOVE="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} --move-back $disver $impts --force-non-empty-directories --target-dir=\${DATA} &> ${INNOMOVELOG}" INNOMOVE="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} --move-back $disver $impts --force-non-empty-directories --target-dir=\${DATA} &> ${INNOMOVELOG}"
INNOBACKUP="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} --backup $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt --target-dir=\$itmpdir 2> ${INNOBACKUPLOG}" INNOBACKUP="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} --backup $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt --target-dir=\$itmpdir 2> ${INNOBACKUPLOG}"
fi fi
get_stream get_stream
...@@ -845,7 +827,7 @@ then ...@@ -845,7 +827,7 @@ then
if [ $WSREP_SST_OPT_BYPASS -eq 0 ] if [ $WSREP_SST_OPT_BYPASS -eq 0 ]
then then
usrst=0 usrst=0
if [[ -z $sst_ver ]];then if [[ -z $sst_ver ]];then
wsrep_log_error "Upgrade joiner to 5.6.21 or higher for backup locks support" wsrep_log_error "Upgrade joiner to 5.6.21 or higher for backup locks support"
wsrep_log_error "The joiner is not supported for this version of donor" wsrep_log_error "The joiner is not supported for this version of donor"
exit 93 exit 93
...@@ -878,7 +860,7 @@ then ...@@ -878,7 +860,7 @@ then
if [[ $encrypt -eq 1 ]];then if [[ $encrypt -eq 1 ]];then
if [[ -n $ekey ]];then if [[ -n $ekey ]];then
INNOEXTRA+=" --encrypt=$ealgo --encrypt-key=$ekey" INNOEXTRA+=" --encrypt=$ealgo --encrypt-key=$ekey"
else else
INNOEXTRA+=" --encrypt=$ealgo --encrypt-key-file=$ekeyfile" INNOEXTRA+=" --encrypt=$ealgo --encrypt-key-file=$ekeyfile"
fi fi
fi fi
...@@ -894,22 +876,22 @@ then ...@@ -894,22 +876,22 @@ then
ttcmd="$tcmd" ttcmd="$tcmd"
if [[ $encrypt -eq 1 ]];then if [[ $encrypt -eq 1 ]];then
if [[ -n $scomp ]];then if [[ -n $scomp ]];then
tcmd=" $ecmd | $scomp | $tcmd " tcmd=" $ecmd | $scomp | $tcmd "
else else
tcmd=" $ecmd | $tcmd " tcmd=" $ecmd | $tcmd "
fi fi
elif [[ -n $scomp ]];then elif [[ -n $scomp ]];then
tcmd=" $scomp | $tcmd " tcmd=" $scomp | $tcmd "
fi fi
send_donor $DATA "${stagemsg}-gtid" send_donor $DATA "${stagemsg}-gtid"
tcmd="$ttcmd" tcmd="$ttcmd"
if [[ -n $progress ]];then if [[ -n $progress ]];then
get_footprint get_footprint
tcmd="$pcmd | $tcmd" tcmd="$pcmd | $tcmd"
elif [[ -n $rlimit ]];then elif [[ -n $rlimit ]];then
adjust_progress adjust_progress
tcmd="$pcmd | $tcmd" tcmd="$pcmd | $tcmd"
fi fi
...@@ -919,7 +901,7 @@ then ...@@ -919,7 +901,7 @@ then
wsrep_log_info "Streaming the backup to joiner at ${REMOTEIP} ${SST_PORT:-4444}" wsrep_log_info "Streaming the backup to joiner at ${REMOTEIP} ${SST_PORT:-4444}"
if [[ -n $scomp ]];then if [[ -n $scomp ]];then
tcmd="$scomp | $tcmd" tcmd="$scomp | $tcmd"
fi fi
...@@ -931,7 +913,7 @@ then ...@@ -931,7 +913,7 @@ then
wsrep_log_error "${INNOBACKUPEX_BIN} finished with error: ${RC[0]}. " \ wsrep_log_error "${INNOBACKUPEX_BIN} finished with error: ${RC[0]}. " \
"Check syslog or ${INNOBACKUPLOG} for details" "Check syslog or ${INNOBACKUPLOG} for details"
exit 22 exit 22
elif [[ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ]];then elif [[ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ]];then
wsrep_log_error "$tcmd finished with error: ${RC[1]}" wsrep_log_error "$tcmd finished with error: ${RC[1]}"
exit 22 exit 22
fi fi
...@@ -939,7 +921,6 @@ then ...@@ -939,7 +921,6 @@ then
# innobackupex implicitly writes PID to fixed location in $xtmpdir # innobackupex implicitly writes PID to fixed location in $xtmpdir
XTRABACKUP_PID="$xtmpdir/xtrabackup_pid" XTRABACKUP_PID="$xtmpdir/xtrabackup_pid"
else # BYPASS FOR IST else # BYPASS FOR IST
wsrep_log_info "Bypassing the SST for IST" wsrep_log_info "Bypassing the SST for IST"
...@@ -951,12 +932,12 @@ then ...@@ -951,12 +932,12 @@ then
echo "1" > "${DATA}/${IST_FILE}" echo "1" > "${DATA}/${IST_FILE}"
get_keys get_keys
if [[ $encrypt -eq 1 ]];then if [[ $encrypt -eq 1 ]];then
if [[ -n $scomp ]];then if [[ -n $scomp ]];then
tcmd=" $ecmd | $scomp | $tcmd " tcmd=" $ecmd | $scomp | $tcmd "
else else
tcmd=" $ecmd | $tcmd " tcmd=" $ecmd | $tcmd "
fi fi
elif [[ -n $scomp ]];then elif [[ -n $scomp ]];then
tcmd=" $scomp | $tcmd " tcmd=" $scomp | $tcmd "
fi fi
strmcmd+=" \${IST_FILE}" strmcmd+=" \${IST_FILE}"
...@@ -1003,7 +984,6 @@ then ...@@ -1003,7 +984,6 @@ then
stagemsg="Joiner-Recv" stagemsg="Joiner-Recv"
sencrypted=1 sencrypted=1
nthreads=1 nthreads=1
...@@ -1030,30 +1010,29 @@ then ...@@ -1030,30 +1010,29 @@ then
trap sig_joiner_cleanup HUP PIPE INT TERM trap sig_joiner_cleanup HUP PIPE INT TERM
trap cleanup_joiner EXIT trap cleanup_joiner EXIT
if [[ -n $progress ]];then if [[ -n $progress ]];then
adjust_progress adjust_progress
tcmd+=" | $pcmd" tcmd+=" | $pcmd"
fi fi
get_keys get_keys
if [[ $encrypt -eq 1 && $sencrypted -eq 1 ]];then if [[ $encrypt -eq 1 && $sencrypted -eq 1 ]];then
if [[ -n $sdecomp ]];then if [[ -n $sdecomp ]];then
strmcmd=" $sdecomp | $ecmd | $strmcmd" strmcmd=" $sdecomp | $ecmd | $strmcmd"
else else
strmcmd=" $ecmd | $strmcmd" strmcmd=" $ecmd | $strmcmd"
fi fi
elif [[ -n $sdecomp ]];then elif [[ -n $sdecomp ]];then
strmcmd=" $sdecomp | $strmcmd" strmcmd=" $sdecomp | $strmcmd"
fi fi
STATDIR=$(mktemp -d) STATDIR=$(mktemp -d)
MAGIC_FILE="${STATDIR}/${INFO_FILE}" MAGIC_FILE="${STATDIR}/${INFO_FILE}"
recv_joiner $STATDIR "${stagemsg}-gtid" $stimeout 1 recv_joiner $STATDIR "${stagemsg}-gtid" $stimeout 1
if ! ps -p ${WSREP_SST_OPT_PARENT} &>/dev/null if ! ps -p ${WSREP_SST_OPT_PARENT} &>/dev/null
then then
wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly." wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly."
exit 32 exit 32
fi fi
...@@ -1070,11 +1049,11 @@ then ...@@ -1070,11 +1049,11 @@ then
wsrep_log_info "Proceeding with SST" wsrep_log_info "Proceeding with SST"
wsrep_log_info "Cleaning the existing datadir and innodb-data/log directories" wsrep_log_info "Cleaning the existing datadir and innodb-data/log directories"
if [ "${OS}" = "FreeBSD" ]; then if [ "${OS}" = "FreeBSD" ]; then
find -E $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1 -prune -regex $cpat -o -exec rm -rfv {} 1>&2 \+ find -E $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1 -prune -regex $cpat -o -exec rm -rfv {} 1>&2 \+
else else
find $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1 -prune -regex $cpat -o -exec rm -rfv {} 1>&2 \+ find $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1 -prune -regex $cpat -o -exec rm -rfv {} 1>&2 \+
fi fi
tempdir=$LOG_BIN_ARG tempdir=$LOG_BIN_ARG
if [ -z "$tempdir" ]; then if [ -z "$tempdir" ]; then
...@@ -1094,30 +1073,27 @@ then ...@@ -1094,30 +1073,27 @@ then
fi fi
fi fi
TDATA=${DATA} TDATA=${DATA}
DATA="${DATA}/.sst" DATA="${DATA}/.sst"
MAGIC_FILE="${DATA}/${INFO_FILE}" MAGIC_FILE="${DATA}/${INFO_FILE}"
wsrep_log_info "Waiting for SST streaming to complete!" wsrep_log_info "Waiting for SST streaming to complete!"
monitor_process $jpid monitor_process $jpid
get_proc get_proc
if [[ ! -s ${DATA}/xtrabackup_checkpoints ]];then if [[ ! -s ${DATA}/xtrabackup_checkpoints ]];then
wsrep_log_error "xtrabackup_checkpoints missing, failed innobackupex/SST on donor" wsrep_log_error "xtrabackup_checkpoints missing, failed innobackupex/SST on donor"
exit 2 exit 2
fi fi
# Rebuild indexes for compact backups # Rebuild indexes for compact backups
if grep -q 'compact = 1' ${DATA}/xtrabackup_checkpoints;then if grep -q 'compact = 1' ${DATA}/xtrabackup_checkpoints;then
wsrep_log_info "Index compaction detected" wsrep_log_info "Index compaction detected"
rebuild=1 rebuild=1
fi fi
if [[ $rebuild -eq 1 ]];then if [[ $rebuild -eq 1 ]];then
nthreads=$(parse_cnf xtrabackup rebuild-threads $nproc) nthreads=$(parse_cnf xtrabackup rebuild-threads $nproc)
wsrep_log_info "Rebuilding during prepare with $nthreads threads" wsrep_log_info "Rebuilding during prepare with $nthreads threads"
rebuildcmd="--rebuild-indexes --rebuild-threads=$nthreads" rebuildcmd="--rebuild-indexes --rebuild-threads=$nthreads"
...@@ -1127,7 +1103,7 @@ then ...@@ -1127,7 +1103,7 @@ then
wsrep_log_info "Compressed qpress files found" wsrep_log_info "Compressed qpress files found"
if ! command -v qpress >/dev/null;then if ! command -v qpress >/dev/null;then
wsrep_log_error "qpress not found in path: $PATH" wsrep_log_error "qpress not found in path: $PATH"
exit 22 exit 22
fi fi
...@@ -1135,28 +1111,27 @@ then ...@@ -1135,28 +1111,27 @@ then
if [[ -n $progress ]] && pv --help | grep -q 'line-mode';then if [[ -n $progress ]] && pv --help | grep -q 'line-mode';then
count=$(find ${DATA} -type f -name '*.qp' | wc -l) count=$(find ${DATA} -type f -name '*.qp' | wc -l)
count=$(( count*2 )) count=$(( count*2 ))
if pv --help | grep -q FORMAT;then if pv --help | grep -q FORMAT;then
pvopts="-f -s $count -l -N Decompression -F '%N => Rate:%r Elapsed:%t %e Progress: [%b/$count]'" pvopts="-f -s $count -l -N Decompression -F '%N => Rate:%r Elapsed:%t %e Progress: [%b/$count]'"
else else
pvopts="-f -s $count -l -N Decompression" pvopts="-f -s $count -l -N Decompression"
fi fi
pcmd="pv $pvopts" pcmd="pv $pvopts"
adjust_progress adjust_progress
dcmd="$pcmd | xargs -n 2 qpress -T${nproc}d" dcmd="$pcmd | xargs -n 2 qpress -T${nproc}d"
else else
dcmd="xargs -n 2 qpress -T${nproc}d" dcmd="xargs -n 2 qpress -T${nproc}d"
fi fi
# Decompress the qpress files
# Decompress the qpress files
wsrep_log_info "Decompression with $nproc threads" wsrep_log_info "Decompression with $nproc threads"
timeit "Joiner-Decompression" "find ${DATA} -type f -name '*.qp' -printf '%p\n%h\n' | $dcmd" timeit "Joiner-Decompression" "find ${DATA} -type f -name '*.qp' -printf '%p\n%h\n' | $dcmd"
extcode=$? extcode=$?
if [[ $extcode -eq 0 ]];then if [[ $extcode -eq 0 ]];then
wsrep_log_info "Removing qpress files after decompression" wsrep_log_info "Removing qpress files after decompression"
find ${DATA} -type f -name '*.qp' -delete find ${DATA} -type f -name '*.qp' -delete
if [[ $? -ne 0 ]];then if [[ $? -ne 0 ]];then
wsrep_log_error "Something went wrong with deletion of qpress files. Investigate" wsrep_log_error "Something went wrong with deletion of qpress files. Investigate"
fi fi
else else
...@@ -1165,13 +1140,12 @@ then ...@@ -1165,13 +1140,12 @@ then
fi fi
fi fi
if [[ ! -z $WSREP_SST_OPT_BINLOG ]];then if [[ ! -z $WSREP_SST_OPT_BINLOG ]];then
BINLOG_DIRNAME=$(dirname $WSREP_SST_OPT_BINLOG) BINLOG_DIRNAME=$(dirname $WSREP_SST_OPT_BINLOG)
BINLOG_FILENAME=$(basename $WSREP_SST_OPT_BINLOG) BINLOG_FILENAME=$(basename $WSREP_SST_OPT_BINLOG)
# To avoid comparing data directory and BINLOG_DIRNAME # To avoid comparing data directory and BINLOG_DIRNAME
mv $DATA/${BINLOG_FILENAME}.* $BINLOG_DIRNAME/ 2>/dev/null || true mv $DATA/${BINLOG_FILENAME}.* $BINLOG_DIRNAME/ 2>/dev/null || true
pushd $BINLOG_DIRNAME &>/dev/null pushd $BINLOG_DIRNAME &>/dev/null
...@@ -1187,7 +1161,7 @@ then ...@@ -1187,7 +1161,7 @@ then
if [ $? -ne 0 ]; if [ $? -ne 0 ];
then then
wsrep_log_error "${INNOBACKUPEX_BIN} apply finished with errors. Check syslog or ${INNOAPPLYLOG} for details" wsrep_log_error "${INNOBACKUPEX_BIN} apply finished with errors. Check syslog or ${INNOAPPLYLOG} for details"
exit 22 exit 22
fi fi
...@@ -1196,27 +1170,29 @@ then ...@@ -1196,27 +1170,29 @@ then
set -e set -e
wsrep_log_info "Moving the backup to ${TDATA}" wsrep_log_info "Moving the backup to ${TDATA}"
timeit "Xtrabackup move stage" "$INNOMOVE" timeit "Xtrabackup move stage" "$INNOMOVE"
if [[ $? -eq 0 ]];then if [[ $? -eq 0 ]];then
wsrep_log_info "Move successful, removing ${DATA}" wsrep_log_info "Move successful, removing ${DATA}"
rm -rf $DATA rm -rf $DATA
DATA=${TDATA} DATA=${TDATA}
else else
wsrep_log_error "Move failed, keeping ${DATA} for further diagnosis" wsrep_log_error "Move failed, keeping ${DATA} for further diagnosis"
wsrep_log_error "Check syslog or ${INNOMOVELOG} for details" wsrep_log_error "Check syslog or ${INNOMOVELOG} for details"
exit 22 exit 22
fi fi
else
else
wsrep_log_info "${IST_FILE} received from donor: Running IST" wsrep_log_info "${IST_FILE} received from donor: Running IST"
fi fi
if [[ ! -r ${MAGIC_FILE} ]];then if [[ ! -r ${MAGIC_FILE} ]];then
wsrep_log_error "SST magic file ${MAGIC_FILE} not found/readable" wsrep_log_error "SST magic file ${MAGIC_FILE} not found/readable"
exit 2 exit 2
fi fi
wsrep_log_info "Galera co-ords from recovery: $(cat ${MAGIC_FILE})" wsrep_log_info "Galera co-ords from recovery: $(cat ${MAGIC_FILE})"
cat "${MAGIC_FILE}" # Output : UUID:seqno wsrep_gtid_domain_id cat "${MAGIC_FILE}" # Output : UUID:seqno wsrep_gtid_domain_id
wsrep_log_info "Total time on joiner: $totime seconds" wsrep_log_info "Total time on joiner: $totime seconds"
fi fi
......
...@@ -100,12 +100,12 @@ SET_START_POSITION="SET GLOBAL wsrep_start_position='$WSREP_SST_OPT_GTID';" ...@@ -100,12 +100,12 @@ SET_START_POSITION="SET GLOBAL wsrep_start_position='$WSREP_SST_OPT_GTID';"
SET_WSREP_GTID_DOMAIN_ID="" SET_WSREP_GTID_DOMAIN_ID=""
if [ -n $WSREP_SST_OPT_GTID_DOMAIN_ID ] if [ -n $WSREP_SST_OPT_GTID_DOMAIN_ID ]
then then
SET_WSREP_GTID_DOMAIN_ID=" SET_WSREP_GTID_DOMAIN_ID="
SET @val = (SELECT GLOBAL_VALUE FROM INFORMATION_SCHEMA.SYSTEM_VARIABLES WHERE VARIABLE_NAME = 'WSREP_GTID_STRICT_MODE' AND GLOBAL_VALUE > 0); SET @val = (SELECT GLOBAL_VALUE FROM INFORMATION_SCHEMA.SYSTEM_VARIABLES WHERE VARIABLE_NAME = 'WSREP_GTID_STRICT_MODE' AND GLOBAL_VALUE > 0);
SET @stmt = IF (@val IS NOT NULL, 'SET GLOBAL WSREP_GTID_DOMAIN_ID=$WSREP_SST_OPT_GTID_DOMAIN_ID', 'SET @dummy = 0'); SET @stmt = IF (@val IS NOT NULL, 'SET GLOBAL WSREP_GTID_DOMAIN_ID=$WSREP_SST_OPT_GTID_DOMAIN_ID', 'SET @dummy = 0');
PREPARE stmt FROM @stmt; PREPARE stmt FROM @stmt;
EXECUTE stmt; EXECUTE stmt;
DROP PREPARE stmt;" DROP PREPARE stmt;"
fi fi
MYSQL="$MYSQL_CLIENT $WSREP_SST_OPT_CONF "\ MYSQL="$MYSQL_CLIENT $WSREP_SST_OPT_CONF "\
...@@ -132,16 +132,16 @@ SQL_LOG_BIN_OFF="" ...@@ -132,16 +132,16 @@ SQL_LOG_BIN_OFF=""
# Safety check # Safety check
if [ "${SERVER_VERSION%%.*}" != '5' ] if [ "${SERVER_VERSION%%.*}" != '5' ]
then then
# If binary logging is enabled on the joiner node, we need to copy donor's # If binary logging is enabled on the joiner node, we need to copy donor's
# gtid_binlog_state to joiner. In order to do that, a RESET MASTER must be # gtid_binlog_state to joiner. In order to do that, a RESET MASTER must be
# executed to erase binary logs (if any). Binary logging should also be # executed to erase binary logs (if any). Binary logging should also be
# turned off for the session so that gtid state does not get altered while # turned off for the session so that gtid state does not get altered while
# the dump gets replayed on joiner. # the dump gets replayed on joiner.
if [[ "$LOG_BIN" == 'ON' ]]; then if [[ "$LOG_BIN" == 'ON' ]]; then
RESET_MASTER="RESET MASTER;" RESET_MASTER="RESET MASTER;"
SET_GTID_BINLOG_STATE="SET @@global.gtid_binlog_state='$GTID_BINLOG_STATE';" SET_GTID_BINLOG_STATE="SET @@global.gtid_binlog_state='$GTID_BINLOG_STATE';"
SQL_LOG_BIN_OFF="SET @@session.sql_log_bin=OFF;" SQL_LOG_BIN_OFF="SET @@session.sql_log_bin=OFF;"
fi fi
fi fi
# NOTE: we don't use --routines here because we're dumping mysql.proc table # NOTE: we don't use --routines here because we're dumping mysql.proc table
......
...@@ -74,8 +74,8 @@ check_pid_and_port() ...@@ -74,8 +74,8 @@ check_pid_and_port()
;; ;;
*) *)
if ! which lsof > /dev/null; then if ! which lsof > /dev/null; then
wsrep_log_error "lsof tool not found in PATH! Make sure you have it installed." wsrep_log_error "lsof tool not found in PATH! Make sure you have it installed."
exit 2 # ENOENT exit 2 # ENOENT
fi fi
local port_info="$(lsof -i :$rsync_port -Pn 2>/dev/null | \ local port_info="$(lsof -i :$rsync_port -Pn 2>/dev/null | \
...@@ -107,15 +107,15 @@ is_local_ip() ...@@ -107,15 +107,15 @@ is_local_ip()
local get_addr_bin=`which ifconfig` local get_addr_bin=`which ifconfig`
if [ -z "$get_addr_bin" ] if [ -z "$get_addr_bin" ]
then then
get_addr_bin=`which ip` get_addr_bin=`which ip`
get_addr_bin="$get_addr_bin address show" get_addr_bin="$get_addr_bin address show"
# Add an slash at the end, so we don't get false positive : 172.18.0.4 matches 172.18.0.41 # Add an slash at the end, so we don't get false positive : 172.18.0.4 matches 172.18.0.41
# ip output format is "X.X.X.X/mask" # ip output format is "X.X.X.X/mask"
address="${address}/" address="${address}/"
else else
# Add an space at the end, so we don't get false positive : 172.18.0.4 matches 172.18.0.41 # Add an space at the end, so we don't get false positive : 172.18.0.4 matches 172.18.0.41
# ifconfig output format is "X.X.X.X " # ifconfig output format is "X.X.X.X "
address="$address " address="$address "
fi fi
$get_addr_bin | grep -F "$address" > /dev/null $get_addr_bin | grep -F "$address" > /dev/null
...@@ -373,11 +373,13 @@ EOF ...@@ -373,11 +373,13 @@ EOF
fi fi
else # BYPASS else # BYPASS
wsrep_log_info "Bypassing state dump." wsrep_log_info "Bypassing state dump."
# Store donor's wsrep GTID (state ID) and wsrep_gtid_domain_id # Store donor's wsrep GTID (state ID) and wsrep_gtid_domain_id
# (separated by a space). # (separated by a space).
STATE="$WSREP_SST_OPT_GTID $WSREP_SST_OPT_GTID_DOMAIN_ID" STATE="$WSREP_SST_OPT_GTID $WSREP_SST_OPT_GTID_DOMAIN_ID"
fi fi
echo "continue" # now server can resume updating data echo "continue" # now server can resume updating data
...@@ -461,22 +463,22 @@ EOF ...@@ -461,22 +463,22 @@ EOF
# If the IP is local listen only in it # If the IP is local listen only in it
if is_local_ip "$RSYNC_ADDR" if is_local_ip "$RSYNC_ADDR"
then then
RSYNC_EXTRA_ARGS="--address $RSYNC_ADDR" RSYNC_EXTRA_ARGS="--address $RSYNC_ADDR"
STUNNEL_ACCEPT="$RSYNC_ADDR:$RSYNC_PORT" STUNNEL_ACCEPT="$RSYNC_ADDR:$RSYNC_PORT"
else else
# Not local, possibly a NAT, listen on all interfaces # Not local, possibly a NAT, listen on all interfaces
RSYNC_EXTRA_ARGS="" RSYNC_EXTRA_ARGS=""
STUNNEL_ACCEPT="$RSYNC_PORT" STUNNEL_ACCEPT="$RSYNC_PORT"
# Overwrite address with all # Overwrite address with all
RSYNC_ADDR="*" RSYNC_ADDR="*"
fi fi
if [ -z "$STUNNEL" ] if [ -z "$STUNNEL" ]
then then
rsync --daemon --no-detach --port "$RSYNC_PORT" --config "$RSYNC_CONF" ${RSYNC_EXTRA_ARGS} & rsync --daemon --no-detach --port "$RSYNC_PORT" --config "$RSYNC_CONF" ${RSYNC_EXTRA_ARGS} &
RSYNC_REAL_PID=$! RSYNC_REAL_PID=$!
else else
cat << EOF > "$STUNNEL_CONF" cat << EOF > "$STUNNEL_CONF"
key = $SSTKEY key = $SSTKEY
cert = $SSTCERT cert = $SSTCERT
foreground = yes foreground = yes
...@@ -488,9 +490,9 @@ accept = $STUNNEL_ACCEPT ...@@ -488,9 +490,9 @@ accept = $STUNNEL_ACCEPT
exec = $(which rsync) exec = $(which rsync)
execargs = rsync --server --daemon --config=$RSYNC_CONF . execargs = rsync --server --daemon --config=$RSYNC_CONF .
EOF EOF
stunnel "$STUNNEL_CONF" & stunnel "$STUNNEL_CONF" &
RSYNC_REAL_PID=$! RSYNC_REAL_PID=$!
RSYNC_PID=$STUNNEL_PID RSYNC_PID=$STUNNEL_PID
fi fi
until check_pid_and_port "$RSYNC_PID" "$RSYNC_REAL_PID" "$RSYNC_ADDR" "$RSYNC_PORT" until check_pid_and_port "$RSYNC_PID" "$RSYNC_REAL_PID" "$RSYNC_ADDR" "$RSYNC_PORT"
...@@ -518,7 +520,6 @@ EOF ...@@ -518,7 +520,6 @@ EOF
if ! [ -z $WSREP_SST_OPT_BINLOG ] if ! [ -z $WSREP_SST_OPT_BINLOG ]
then then
OLD_PWD="$(pwd)" OLD_PWD="$(pwd)"
cd $BINLOG_DIRNAME cd $BINLOG_DIRNAME
...@@ -532,14 +533,15 @@ EOF ...@@ -532,14 +533,15 @@ EOF
do do
if ! [ -z $WSREP_SST_OPT_BINLOG_INDEX ] if ! [ -z $WSREP_SST_OPT_BINLOG_INDEX ]
echo ${BINLOG_DIRNAME}/${ii} >> ${BINLOG_FILENAME}.index echo ${BINLOG_DIRNAME}/${ii} >> ${BINLOG_FILENAME}.index
then then
echo ${BINLOG_DIRNAME}/${ii} >> ${BINLOG_INDEX_DIRNAME}/${BINLOG_INDEX_FILENAME}.index echo ${BINLOG_DIRNAME}/${ii} >> ${BINLOG_INDEX_DIRNAME}/${BINLOG_INDEX_FILENAME}.index
fi fi
done done
fi fi
cd "$OLD_PWD"
cd "$OLD_PWD"
fi fi
if [ -r "$MAGIC_FILE" ] if [ -r "$MAGIC_FILE" ]
then then
# UUID:seqno & wsrep_gtid_domain_id is received here. # UUID:seqno & wsrep_gtid_domain_id is received here.
...@@ -548,6 +550,7 @@ EOF ...@@ -548,6 +550,7 @@ EOF
# this message should cause joiner to abort # this message should cause joiner to abort
echo "rsync process ended without creating '$MAGIC_FILE'" echo "rsync process ended without creating '$MAGIC_FILE'"
fi fi
wsrep_cleanup_progress_file wsrep_cleanup_progress_file
# cleanup_joiner # cleanup_joiner
else else
......
...@@ -15,12 +15,9 @@ ...@@ -15,12 +15,9 @@
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston
# MA 02110-1335 USA. # MA 02110-1335 USA.
# Documentation: http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html # Documentation: http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html
# Make sure to read that before proceeding! # Make sure to read that before proceeding!
. $(dirname $0)/wsrep_sst_common . $(dirname $0)/wsrep_sst_common
ealgo="" ealgo=""
...@@ -73,7 +70,7 @@ ssl_cert="" ...@@ -73,7 +70,7 @@ ssl_cert=""
ssl_ca="" ssl_ca=""
ssl_key="" ssl_key=""
if which pv &>/dev/null && pv --help | grep -q FORMAT;then if which pv &>/dev/null && pv --help | grep -q FORMAT;then
pvopts+=$pvformat pvopts+=$pvformat
fi fi
pcmd="pv $pvopts" pcmd="pv $pvopts"
...@@ -101,7 +98,7 @@ timeit(){ ...@@ -101,7 +98,7 @@ timeit(){
local cmd="$@" local cmd="$@"
local x1 x2 took extcode local x1 x2 took extcode
if [[ $ttime -eq 1 ]];then if [[ $ttime -eq 1 ]];then
x1=$(date +%s) x1=$(date +%s)
wsrep_log_info "Evaluating $cmd" wsrep_log_info "Evaluating $cmd"
eval "$cmd" eval "$cmd"
...@@ -110,7 +107,7 @@ timeit(){ ...@@ -110,7 +107,7 @@ timeit(){
took=$(( x2-x1 )) took=$(( x2-x1 ))
wsrep_log_info "NOTE: $stage took $took seconds" wsrep_log_info "NOTE: $stage took $took seconds"
totime=$(( totime+took )) totime=$(( totime+took ))
else else
wsrep_log_info "Evaluating $cmd" wsrep_log_info "Evaluating $cmd"
eval "$cmd" eval "$cmd"
extcode=$? extcode=$?
...@@ -121,11 +118,11 @@ timeit(){ ...@@ -121,11 +118,11 @@ timeit(){
get_keys() get_keys()
{ {
# $encrypt -eq 1 is for internal purposes only # $encrypt -eq 1 is for internal purposes only
if [[ $encrypt -ge 2 || $encrypt -eq -1 ]];then if [[ $encrypt -ge 2 || $encrypt -eq -1 ]];then
return return
fi fi
if [[ $encrypt -eq 0 ]];then if [[ $encrypt -eq 0 ]];then
if $MY_PRINT_DEFAULTS xtrabackup | grep -q encrypt;then if $MY_PRINT_DEFAULTS xtrabackup | grep -q encrypt;then
wsrep_log_error "Unexpected option combination. SST may fail. Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html " wsrep_log_error "Unexpected option combination. SST may fail. Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html "
fi fi
...@@ -252,7 +249,7 @@ get_transfer() ...@@ -252,7 +249,7 @@ get_transfer()
TSST_PORT=${WSREP_SST_OPT_PORT:-4444} TSST_PORT=${WSREP_SST_OPT_PORT:-4444}
if [[ $tfmt == 'nc' ]];then if [[ $tfmt == 'nc' ]];then
if [[ ! -x `which nc` ]];then if [[ ! -x `which nc` ]];then
wsrep_log_error "nc(netcat) not found in path: $PATH" wsrep_log_error "nc(netcat) not found in path: $PATH"
exit 2 exit 2
fi fi
...@@ -292,7 +289,7 @@ get_transfer() ...@@ -292,7 +289,7 @@ get_transfer()
else else
tfmt='socat' tfmt='socat'
wsrep_log_info "Using socat as streamer" wsrep_log_info "Using socat as streamer"
if [[ ! -x `which socat` ]];then if [[ ! -x `which socat` ]];then
wsrep_log_error "socat not found in path: $PATH" wsrep_log_error "socat not found in path: $PATH"
exit 2 exit 2
fi fi
...@@ -389,7 +386,6 @@ get_transfer() ...@@ -389,7 +386,6 @@ get_transfer()
wsrep_log_info "Encrypting with CERT: $ssl_cert, KEY: $ssl_key, CA: $ssl_ca" wsrep_log_info "Encrypting with CERT: $ssl_cert, KEY: $ssl_key, CA: $ssl_ca"
tcmd="socat -u stdio openssl-connect:${WSREP_SST_OPT_HOST}:${TSST_PORT},cert=${ssl_cert},key=${ssl_key},cafile=${ssl_ca},verify=1${donor_extra}${sockopt}" tcmd="socat -u stdio openssl-connect:${WSREP_SST_OPT_HOST}:${TSST_PORT},cert=${ssl_cert},key=${ssl_key},cafile=${ssl_ca},verify=1${donor_extra}${sockopt}"
fi fi
else else
if [[ $encrypt -eq 1 ]]; then if [[ $encrypt -eq 1 ]]; then
wsrep_log_warning "**** WARNING **** encrypt=1 is deprecated and will be removed in a future release" wsrep_log_warning "**** WARNING **** encrypt=1 is deprecated and will be removed in a future release"
...@@ -408,7 +404,7 @@ get_footprint() ...@@ -408,7 +404,7 @@ get_footprint()
{ {
pushd $WSREP_SST_OPT_DATA 1>/dev/null pushd $WSREP_SST_OPT_DATA 1>/dev/null
payload=$(find . -regex '.*\.ibd$\|.*\.MYI$\|.*\.MYD$\|.*ibdata1$' -type f -print0 | du --files0-from=- --block-size=1 -c -s | awk 'END { print $1 }') payload=$(find . -regex '.*\.ibd$\|.*\.MYI$\|.*\.MYD$\|.*ibdata1$' -type f -print0 | du --files0-from=- --block-size=1 -c -s | awk 'END { print $1 }')
if $MY_PRINT_DEFAULTS xtrabackup | grep -q -- "--compress";then if $MY_PRINT_DEFAULTS xtrabackup | grep -q -- "--compress";then
# QuickLZ has around 50% compression ratio # QuickLZ has around 50% compression ratio
# When compression/compaction used, the progress is only an approximate. # When compression/compaction used, the progress is only an approximate.
payload=$(( payload*1/2 )) payload=$(( payload*1/2 ))
...@@ -420,8 +416,7 @@ get_footprint() ...@@ -420,8 +416,7 @@ get_footprint()
adjust_progress() adjust_progress()
{ {
if [[ ! -x `which pv` ]];then
if [[ ! -x `which pv` ]];then
wsrep_log_error "pv not found in path: $PATH" wsrep_log_error "pv not found in path: $PATH"
wsrep_log_error "Disabling all progress/rate-limiting" wsrep_log_error "Disabling all progress/rate-limiting"
pcmd="" pcmd=""
...@@ -430,16 +425,16 @@ adjust_progress() ...@@ -430,16 +425,16 @@ adjust_progress()
return return
fi fi
if [[ -n $progress && $progress != '1' ]];then if [[ -n $progress && $progress != '1' ]];then
if [[ -e $progress ]];then if [[ -e $progress ]];then
pcmd+=" 2>>$progress" pcmd+=" 2>>$progress"
else else
pcmd+=" 2>$progress" pcmd+=" 2>$progress"
fi fi
elif [[ -z $progress && -n $rlimit ]];then elif [[ -z $progress && -n $rlimit ]];then
# When rlimit is non-zero # When rlimit is non-zero
pcmd="pv -q" pcmd="pv -q"
fi fi
if [[ -n $rlimit && "$WSREP_SST_OPT_ROLE" == "donor" ]];then if [[ -n $rlimit && "$WSREP_SST_OPT_ROLE" == "donor" ]];then
wsrep_log_info "Rate-limiting SST to $rlimit" wsrep_log_info "Rate-limiting SST to $rlimit"
...@@ -470,8 +465,7 @@ read_cnf() ...@@ -470,8 +465,7 @@ read_cnf()
scomp=$(parse_cnf sst compressor "") scomp=$(parse_cnf sst compressor "")
sdecomp=$(parse_cnf sst decompressor "") sdecomp=$(parse_cnf sst decompressor "")
# Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html
# Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html
if [[ -z $ealgo ]];then if [[ -z $ealgo ]];then
ealgo=$(parse_cnf sst encrypt-algo "") ealgo=$(parse_cnf sst encrypt-algo "")
ekey=$(parse_cnf sst encrypt-key "") ekey=$(parse_cnf sst encrypt-key "")
...@@ -502,7 +496,7 @@ read_cnf() ...@@ -502,7 +496,7 @@ read_cnf()
ssystag=$(parse_cnf mysqld_safe syslog-tag "${SST_SYSLOG_TAG:-}") ssystag=$(parse_cnf mysqld_safe syslog-tag "${SST_SYSLOG_TAG:-}")
ssystag+="-" ssystag+="-"
if [[ $ssyslog -ne -1 ]];then if [[ $ssyslog -ne -1 ]];then
if $MY_PRINT_DEFAULTS mysqld_safe | grep -q -- "--syslog";then if $MY_PRINT_DEFAULTS mysqld_safe | grep -q -- "--syslog";then
ssyslog=1 ssyslog=1
fi fi
...@@ -511,7 +505,7 @@ read_cnf() ...@@ -511,7 +505,7 @@ read_cnf()
get_stream() get_stream()
{ {
if [[ $sfmt == 'xbstream' ]];then if [[ $sfmt == 'xbstream' ]];then
wsrep_log_info "Streaming with xbstream" wsrep_log_info "Streaming with xbstream"
if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
strmcmd="xbstream -x" strmcmd="xbstream -x"
...@@ -526,7 +520,6 @@ get_stream() ...@@ -526,7 +520,6 @@ get_stream()
else else
strmcmd="tar cf - \${INFO_FILE} " strmcmd="tar cf - \${INFO_FILE} "
fi fi
fi fi
} }
...@@ -548,33 +541,32 @@ cleanup_joiner() ...@@ -548,33 +541,32 @@ cleanup_joiner()
{ {
# Since this is invoked just after exit NNN # Since this is invoked just after exit NNN
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 [ "${WSREP_SST_OPT_ROLE}" = "joiner" ];then elif [ "${WSREP_SST_OPT_ROLE}" = "joiner" ];then
wsrep_log_info "Removing the sst_in_progress file" wsrep_log_info "Removing the sst_in_progress file"
wsrep_cleanup_progress_file wsrep_cleanup_progress_file
fi fi
if [[ -n $progress && -p $progress ]];then if [[ -n $progress && -p $progress ]];then
wsrep_log_info "Cleaning up fifo file $progress" wsrep_log_info "Cleaning up fifo file $progress"
rm $progress rm $progress
fi fi
if [[ -n ${STATDIR:-} ]];then
if [[ -n ${STATDIR:-} ]];then
[[ -d $STATDIR ]] && rm -rf $STATDIR [[ -d $STATDIR ]] && rm -rf $STATDIR
fi fi
# Final cleanup # Final cleanup
pgid=$(ps -o pgid= $$ | grep -o '[0-9]*') pgid=$(ps -o pgid= $$ | grep -o '[0-9]*')
# This means no setsid done in mysqld. # This means no setsid done in mysqld.
# We don't want to kill mysqld here otherwise. # We don't want to kill mysqld here otherwise.
if [[ $$ -eq $pgid ]];then if [[ $$ -eq $pgid ]];then
# This means a signal was delivered to the process. # This means a signal was delivered to the process.
# So, more cleanup. # So, more cleanup.
if [[ $estatus -ge 128 ]];then if [[ $estatus -ge 128 ]];then
kill -KILL -$$ || true kill -KILL -$$ || true
fi fi
fi fi
exit $estatus exit $estatus
...@@ -590,11 +582,11 @@ cleanup_donor() ...@@ -590,11 +582,11 @@ cleanup_donor()
{ {
# Since this is invoked just after exit NNN # Since this is invoked just after exit NNN
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"
fi fi
if [[ -n ${XTRABACKUP_PID:-} ]];then if [[ -n ${XTRABACKUP_PID:-} ]];then
if check_pid $XTRABACKUP_PID if check_pid $XTRABACKUP_PID
then then
wsrep_log_error "xtrabackup process is still running. Killing... " wsrep_log_error "xtrabackup process is still running. Killing... "
...@@ -602,24 +594,25 @@ cleanup_donor() ...@@ -602,24 +594,25 @@ cleanup_donor()
fi fi
fi fi
rm -f ${DATA}/${IST_FILE} || true rm -f ${DATA}/${IST_FILE} || true
if [[ -n $progress && -p $progress ]];then if [[ -n $progress && -p $progress ]];then
wsrep_log_info "Cleaning up fifo file $progress" wsrep_log_info "Cleaning up fifo file $progress"
rm -f $progress || true rm -f $progress || true
fi fi
wsrep_log_info "Cleaning up temporary directories" wsrep_log_info "Cleaning up temporary directories"
if [[ -n $xtmpdir ]];then if [[ -n $xtmpdir ]];then
[[ -d $xtmpdir ]] && rm -rf $xtmpdir || true [[ -d $xtmpdir ]] && rm -rf $xtmpdir || true
fi fi
if [[ -n $itmpdir ]];then if [[ -n $itmpdir ]];then
[[ -d $itmpdir ]] && rm -rf $itmpdir || true [[ -d $itmpdir ]] && rm -rf $itmpdir || true
fi fi
# Final cleanup # Final cleanup
pgid=$(ps -o pgid= $$ | grep -o '[0-9]*') pgid=$(ps -o pgid= $$ | grep -o '[0-9]*')
# This means no setsid done in mysqld. # This means no setsid done in mysqld.
...@@ -627,15 +620,14 @@ cleanup_donor() ...@@ -627,15 +620,14 @@ cleanup_donor()
if [[ $$ -eq $pgid ]];then if [[ $$ -eq $pgid ]];then
# This means a signal was delivered to the process. # This means a signal was delivered to the process.
# So, more cleanup. # So, more cleanup.
if [[ $estatus -ge 128 ]];then if [[ $estatus -ge 128 ]];then
kill -KILL -$$ || true kill -KILL -$$ || true
fi fi
fi fi
exit $estatus exit $estatus
} }
kill_xtrabackup() kill_xtrabackup()
...@@ -668,20 +660,20 @@ wait_for_listen() ...@@ -668,20 +660,20 @@ wait_for_listen()
check_extra() check_extra()
{ {
local use_socket=1 local use_socket=1
if [[ $uextra -eq 1 ]];then if [[ $uextra -eq 1 ]];then
if [ $(parse_cnf --mysqld thread-handling) = 'pool-of-threads'];then if [ $(parse_cnf --mysqld thread-handling) = 'pool-of-threads'];then
local eport=$(parse_cnf --mysqld extra-port) local eport=$(parse_cnf --mysqld extra-port)
if [[ -n $eport ]];then if [[ -n $eport ]];then
# Xtrabackup works only locally. # Xtrabackup works only locally.
# Hence, setting host to 127.0.0.1 unconditionally. # Hence, setting host to 127.0.0.1 unconditionally.
wsrep_log_info "SST through extra_port $eport" wsrep_log_info "SST through extra_port $eport"
INNOEXTRA+=" --host=127.0.0.1 --port=$eport" INNOEXTRA+=" --host=127.0.0.1 --port=$eport"
use_socket=0 use_socket=0
else else
wsrep_log_error "Extra port $eport null, failing" wsrep_log_error "Extra port $eport null, failing"
exit 1 exit 1
fi fi
else else
wsrep_log_info "Thread pool not set, ignore the option use_extra" wsrep_log_info "Thread pool not set, ignore the option use_extra"
fi fi
fi fi
...@@ -693,7 +685,7 @@ check_extra() ...@@ -693,7 +685,7 @@ check_extra()
recv_joiner() recv_joiner()
{ {
local dir=$1 local dir=$1
local msg=$2 local msg=$2
local tmt=$3 local tmt=$3
local checkf=$4 local checkf=$4
local ltcmd local ltcmd
...@@ -706,27 +698,27 @@ recv_joiner() ...@@ -706,27 +698,27 @@ recv_joiner()
pushd ${dir} 1>/dev/null pushd ${dir} 1>/dev/null
set +e set +e
if [[ $tmt -gt 0 && -x `which timeout` ]];then if [[ $tmt -gt 0 && -x `which timeout` ]];then
if timeout --help | grep -q -- '-k';then if timeout --help | grep -q -- '-k';then
ltcmd="timeout -k $(( tmt+10 )) $tmt $tcmd" ltcmd="timeout -k $(( tmt+10 )) $tmt $tcmd"
else else
ltcmd="timeout -s9 $tmt $tcmd" ltcmd="timeout -s9 $tmt $tcmd"
fi fi
timeit "$msg" "$ltcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )" timeit "$msg" "$ltcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
else else
timeit "$msg" "$tcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )" timeit "$msg" "$tcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
fi fi
set -e set -e
popd 1>/dev/null popd 1>/dev/null
if [[ ${RC[0]} -eq 124 ]];then if [[ ${RC[0]} -eq 124 ]];then
wsrep_log_error "Possible timeout in receving first data from donor in gtid stage" wsrep_log_error "Possible timeout in receving first data from donor in gtid stage"
exit 32 exit 32
fi fi
for ecode in "${RC[@]}";do for ecode in "${RC[@]}";do
if [[ $ecode -ne 0 ]];then if [[ $ecode -ne 0 ]];then
wsrep_log_error "Error while getting data from donor node: " \ wsrep_log_error "Error while getting data from donor node: " \
"exit codes: ${RC[@]}" "exit codes: ${RC[@]}"
exit 32 exit 32
...@@ -736,33 +728,30 @@ recv_joiner() ...@@ -736,33 +728,30 @@ recv_joiner()
if [[ $checkf -eq 1 && ! -r "${MAGIC_FILE}" ]];then if [[ $checkf -eq 1 && ! -r "${MAGIC_FILE}" ]];then
# this message should cause joiner to abort # this message should cause joiner to abort
wsrep_log_error "xtrabackup process ended without creating '${MAGIC_FILE}'" wsrep_log_error "xtrabackup process ended without creating '${MAGIC_FILE}'"
wsrep_log_info "Contents of datadir" wsrep_log_info "Contents of datadir"
wsrep_log_info "$(ls -l ${dir}/*)" wsrep_log_info "$(ls -l ${dir}/*)"
exit 32 exit 32
fi fi
} }
send_donor() send_donor()
{ {
local dir=$1 local dir=$1
local msg=$2 local msg=$2
pushd ${dir} 1>/dev/null pushd ${dir} 1>/dev/null
set +e set +e
timeit "$msg" "$strmcmd | $tcmd; RC=( "\${PIPESTATUS[@]}" )" timeit "$msg" "$strmcmd | $tcmd; RC=( "\${PIPESTATUS[@]}" )"
set -e set -e
popd 1>/dev/null popd 1>/dev/null
for ecode in "${RC[@]}";do for ecode in "${RC[@]}";do
if [[ $ecode -ne 0 ]];then if [[ $ecode -ne 0 ]];then
wsrep_log_error "Error while getting data from donor node: " \ wsrep_log_error "Error while getting data from donor node: " \
"exit codes: ${RC[@]}" "exit codes: ${RC[@]}"
exit 32 exit 32
fi fi
done done
} }
# Returns the version string in a standardized format # Returns the version string in a standardized format
...@@ -774,7 +763,7 @@ normalize_version() ...@@ -774,7 +763,7 @@ normalize_version()
local minor=0 local minor=0
local patch=0 local patch=0
# Only parses purely numeric version numbers, 1.2.3 # Only parses purely numeric version numbers, 1.2.3
# Everything after the first three values are ignored # Everything after the first three values are ignored
if [[ $1 =~ ^([0-9]+)\.([0-9]+)\.?([0-9]*)([\.0-9])*$ ]]; then if [[ $1 =~ ^([0-9]+)\.([0-9]+)\.?([0-9]*)([\.0-9])*$ ]]; then
major=${BASH_REMATCH[1]} major=${BASH_REMATCH[1]}
...@@ -808,12 +797,12 @@ monitor_process() ...@@ -808,12 +797,12 @@ monitor_process()
while true ; do while true ; do
if ! ps --pid "${WSREP_SST_OPT_PARENT}" &>/dev/null; then if ! ps --pid "${WSREP_SST_OPT_PARENT}" &>/dev/null; then
wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly." wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly."
kill -- -"${WSREP_SST_OPT_PARENT}" kill -- -"${WSREP_SST_OPT_PARENT}"
exit 32 exit 32
fi fi
if ! ps --pid "${sst_stream_pid}" &>/dev/null; then if ! ps --pid "${sst_stream_pid}" &>/dev/null; then
break break
fi fi
...@@ -822,8 +811,7 @@ monitor_process() ...@@ -822,8 +811,7 @@ monitor_process()
done done
} }
if [[ ! -x `which $INNOBACKUPEX_BIN` ]];then
if [[ ! -x `which $INNOBACKUPEX_BIN` ]];then
wsrep_log_error "innobackupex not in path: $PATH" wsrep_log_error "innobackupex not in path: $PATH"
exit 2 exit 2
fi fi
...@@ -843,46 +831,43 @@ if ! check_for_version $XB_VERSION $XB_REQUIRED_VERSION; then ...@@ -843,46 +831,43 @@ if ! check_for_version $XB_VERSION $XB_REQUIRED_VERSION; then
exit 2 exit 2
fi fi
rm -f "${MAGIC_FILE}" rm -f "${MAGIC_FILE}"
if [[ ! ${WSREP_SST_OPT_ROLE} == 'joiner' && ! ${WSREP_SST_OPT_ROLE} == 'donor' ]];then if [[ ! ${WSREP_SST_OPT_ROLE} == 'joiner' && ! ${WSREP_SST_OPT_ROLE} == 'donor' ]];then
wsrep_log_error "Invalid role ${WSREP_SST_OPT_ROLE}" wsrep_log_error "Invalid role ${WSREP_SST_OPT_ROLE}"
exit 22 exit 22
fi fi
read_cnf read_cnf
if ${INNOBACKUPEX_BIN} /tmp --help 2>/dev/null | grep -q -- '--version-check'; then if ${INNOBACKUPEX_BIN} /tmp --help 2>/dev/null | grep -q -- '--version-check'; then
disver="--no-version-check" disver="--no-version-check"
fi fi
if [[ ${FORCE_FTWRL:-0} -eq 1 ]];then if [[ ${FORCE_FTWRL:-0} -eq 1 ]];then
wsrep_log_info "Forcing FTWRL due to environment variable FORCE_FTWRL equal to $FORCE_FTWRL" wsrep_log_info "Forcing FTWRL due to environment variable FORCE_FTWRL equal to $FORCE_FTWRL"
iopts+=" --no-backup-locks " iopts+=" --no-backup-locks "
fi fi
INNOEXTRA="" INNOEXTRA=""
if [[ $ssyslog -eq 1 ]];then if [[ $ssyslog -eq 1 ]];then
if [[ ! -x `which logger` ]];then if [[ ! -x `which logger` ]];then
wsrep_log_error "logger not in path: $PATH. Ignoring" wsrep_log_error "logger not in path: $PATH. Ignoring"
else else
wsrep_log_info "Logging all stderr of SST/Innobackupex to syslog" wsrep_log_info "Logging all stderr of SST/Innobackupex to syslog"
exec 2> >(logger -p daemon.err -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE) exec 2> >(logger -p daemon.err -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE)
wsrep_log_error() wsrep_log_error()
{ {
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_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 "$@"
} }
INNOAPPLY="2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-apply " INNOAPPLY="2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-apply "
...@@ -890,7 +875,7 @@ if [[ $ssyslog -eq 1 ]];then ...@@ -890,7 +875,7 @@ if [[ $ssyslog -eq 1 ]];then
INNOBACKUP="2> >(logger -p daemon.err -t ${ssystag}innobackupex-backup)" INNOBACKUP="2> >(logger -p daemon.err -t ${ssystag}innobackupex-backup)"
fi fi
else else
INNOAPPLY="&>\${DATA}/innobackup.prepare.log" INNOAPPLY="&>\${DATA}/innobackup.prepare.log"
INNOMOVE="&>\${DATA}/innobackup.move.log" INNOMOVE="&>\${DATA}/innobackup.move.log"
INNOBACKUP="2>\${DATA}/innobackup.backup.log" INNOBACKUP="2>\${DATA}/innobackup.backup.log"
...@@ -976,12 +961,12 @@ then ...@@ -976,12 +961,12 @@ then
ttcmd="$tcmd" ttcmd="$tcmd"
if [[ $encrypt -eq 1 ]];then if [[ $encrypt -eq 1 ]];then
if [[ -n $scomp ]];then if [[ -n $scomp ]];then
tcmd=" \$ecmd | $scomp | $tcmd " tcmd=" \$ecmd | $scomp | $tcmd "
else else
tcmd=" \$ecmd | $tcmd " tcmd=" \$ecmd | $tcmd "
fi fi
elif [[ -n $scomp ]];then elif [[ -n $scomp ]];then
tcmd=" $scomp | $tcmd " tcmd=" $scomp | $tcmd "
fi fi
...@@ -989,10 +974,10 @@ then ...@@ -989,10 +974,10 @@ then
# Restore the transport commmand to its original state # Restore the transport commmand to its original state
tcmd="$ttcmd" tcmd="$ttcmd"
if [[ -n $progress ]];then if [[ -n $progress ]];then
get_footprint get_footprint
tcmd="$pcmd | $tcmd" tcmd="$pcmd | $tcmd"
elif [[ -n $rlimit ]];then elif [[ -n $rlimit ]];then
adjust_progress adjust_progress
tcmd="$pcmd | $tcmd" tcmd="$pcmd | $tcmd"
fi fi
...@@ -1020,7 +1005,7 @@ then ...@@ -1020,7 +1005,7 @@ then
wsrep_log_error "${INNOBACKUPEX_BIN} finished with error: ${RC[0]}. " \ wsrep_log_error "${INNOBACKUPEX_BIN} finished with error: ${RC[0]}. " \
"Check ${DATA}/innobackup.backup.log" "Check ${DATA}/innobackup.backup.log"
exit 22 exit 22
elif [[ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ]];then elif [[ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ]];then
wsrep_log_error "$tcmd finished with error: ${RC[1]}" wsrep_log_error "$tcmd finished with error: ${RC[1]}"
exit 22 exit 22
fi fi
...@@ -1028,7 +1013,6 @@ then ...@@ -1028,7 +1013,6 @@ then
# innobackupex implicitly writes PID to fixed location in $xtmpdir # innobackupex implicitly writes PID to fixed location in $xtmpdir
XTRABACKUP_PID="$xtmpdir/xtrabackup_pid" XTRABACKUP_PID="$xtmpdir/xtrabackup_pid"
else # BYPASS FOR IST else # BYPASS FOR IST
wsrep_log_info "Bypassing the SST for IST" wsrep_log_info "Bypassing the SST for IST"
...@@ -1040,12 +1024,12 @@ then ...@@ -1040,12 +1024,12 @@ then
echo "1" > "${DATA}/${IST_FILE}" echo "1" > "${DATA}/${IST_FILE}"
get_keys get_keys
if [[ $encrypt -eq 1 ]];then if [[ $encrypt -eq 1 ]];then
if [[ -n $scomp ]];then if [[ -n $scomp ]];then
tcmd=" \$ecmd | $scomp | $tcmd " tcmd=" \$ecmd | $scomp | $tcmd "
else else
tcmd=" \$ecmd | $tcmd " tcmd=" \$ecmd | $tcmd "
fi fi
elif [[ -n $scomp ]];then elif [[ -n $scomp ]];then
tcmd=" $scomp | $tcmd " tcmd=" $scomp | $tcmd "
fi fi
strmcmd+=" \${IST_FILE}" strmcmd+=" \${IST_FILE}"
...@@ -1099,19 +1083,19 @@ then ...@@ -1099,19 +1083,19 @@ then
trap sig_joiner_cleanup HUP PIPE INT TERM trap sig_joiner_cleanup HUP PIPE INT TERM
trap cleanup_joiner EXIT trap cleanup_joiner EXIT
if [[ -n $progress ]];then if [[ -n $progress ]];then
adjust_progress adjust_progress
tcmd+=" | $pcmd" tcmd+=" | $pcmd"
fi fi
get_keys get_keys
if [[ $encrypt -eq 1 && $sencrypted -eq 1 ]];then if [[ $encrypt -eq 1 && $sencrypted -eq 1 ]];then
if [[ -n $sdecomp ]];then if [[ -n $sdecomp ]];then
strmcmd=" $sdecomp | \$ecmd | $strmcmd" strmcmd=" $sdecomp | \$ecmd | $strmcmd"
else else
strmcmd=" \$ecmd | $strmcmd" strmcmd=" \$ecmd | $strmcmd"
fi fi
elif [[ -n $sdecomp ]];then elif [[ -n $sdecomp ]];then
strmcmd=" $sdecomp | $strmcmd" strmcmd=" $sdecomp | $strmcmd"
fi fi
...@@ -1119,10 +1103,9 @@ then ...@@ -1119,10 +1103,9 @@ then
MAGIC_FILE="${STATDIR}/${INFO_FILE}" MAGIC_FILE="${STATDIR}/${INFO_FILE}"
recv_joiner $STATDIR "${stagemsg}-gtid" $stimeout 1 recv_joiner $STATDIR "${stagemsg}-gtid" $stimeout 1
if ! ps -p ${WSREP_SST_OPT_PARENT} &>/dev/null if ! ps -p ${WSREP_SST_OPT_PARENT} &>/dev/null
then then
wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly." wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly."
exit 32 exit 32
fi fi
...@@ -1138,7 +1121,6 @@ then ...@@ -1138,7 +1121,6 @@ then
jpid=$! jpid=$!
wsrep_log_info "Proceeding with SST" wsrep_log_info "Proceeding with SST"
wsrep_log_info "Cleaning the existing datadir and innodb-data/log directories" wsrep_log_info "Cleaning the existing datadir and innodb-data/log directories"
if [ "${OS}" = "FreeBSD" ]; then if [ "${OS}" = "FreeBSD" ]; then
find -E $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1 -prune -regex $cpat -o -exec rm -rfv {} 1>&2 \+ find -E $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1 -prune -regex $cpat -o -exec rm -rfv {} 1>&2 \+
...@@ -1164,30 +1146,27 @@ then ...@@ -1164,30 +1146,27 @@ then
fi fi
fi fi
TDATA=${DATA} TDATA=${DATA}
DATA="${DATA}/.sst" DATA="${DATA}/.sst"
MAGIC_FILE="${DATA}/${INFO_FILE}" MAGIC_FILE="${DATA}/${INFO_FILE}"
wsrep_log_info "Waiting for SST streaming to complete!" wsrep_log_info "Waiting for SST streaming to complete!"
monitor_process $jpid monitor_process $jpid
get_proc get_proc
if [[ ! -s ${DATA}/xtrabackup_checkpoints ]];then if [[ ! -s ${DATA}/xtrabackup_checkpoints ]];then
wsrep_log_error "xtrabackup_checkpoints missing, failed innobackupex/SST on donor" wsrep_log_error "xtrabackup_checkpoints missing, failed innobackupex/SST on donor"
exit 2 exit 2
fi fi
# Rebuild indexes for compact backups # Rebuild indexes for compact backups
if grep -q 'compact = 1' ${DATA}/xtrabackup_checkpoints;then if grep -q 'compact = 1' ${DATA}/xtrabackup_checkpoints;then
wsrep_log_info "Index compaction detected" wsrep_log_info "Index compaction detected"
rebuild=1 rebuild=1
fi fi
if [[ $rebuild -eq 1 ]];then if [[ $rebuild -eq 1 ]];then
nthreads=$(parse_cnf xtrabackup rebuild-threads $nproc) nthreads=$(parse_cnf xtrabackup rebuild-threads $nproc)
wsrep_log_info "Rebuilding during prepare with $nthreads threads" wsrep_log_info "Rebuilding during prepare with $nthreads threads"
rebuildcmd="--rebuild-indexes --rebuild-threads=$nthreads" rebuildcmd="--rebuild-indexes --rebuild-threads=$nthreads"
...@@ -1197,7 +1176,7 @@ then ...@@ -1197,7 +1176,7 @@ then
wsrep_log_info "Compressed qpress files found" wsrep_log_info "Compressed qpress files found"
if [[ ! -x `which qpress` ]];then if [[ ! -x `which qpress` ]];then
wsrep_log_error "qpress not found in path: $PATH" wsrep_log_error "qpress not found in path: $PATH"
exit 22 exit 22
fi fi
...@@ -1205,28 +1184,27 @@ then ...@@ -1205,28 +1184,27 @@ then
if [[ -n $progress ]] && pv --help | grep -q 'line-mode';then if [[ -n $progress ]] && pv --help | grep -q 'line-mode';then
count=$(find ${DATA} -type f -name '*.qp' | wc -l) count=$(find ${DATA} -type f -name '*.qp' | wc -l)
count=$(( count*2 )) count=$(( count*2 ))
if pv --help | grep -q FORMAT;then if pv --help | grep -q FORMAT;then
pvopts="-f -s $count -l -N Decompression -F '%N => Rate:%r Elapsed:%t %e Progress: [%b/$count]'" pvopts="-f -s $count -l -N Decompression -F '%N => Rate:%r Elapsed:%t %e Progress: [%b/$count]'"
else else
pvopts="-f -s $count -l -N Decompression" pvopts="-f -s $count -l -N Decompression"
fi fi
pcmd="pv $pvopts" pcmd="pv $pvopts"
adjust_progress adjust_progress
dcmd="$pcmd | xargs -n 2 qpress -T${nproc}d" dcmd="$pcmd | xargs -n 2 qpress -T${nproc}d"
else else
dcmd="xargs -n 2 qpress -T${nproc}d" dcmd="xargs -n 2 qpress -T${nproc}d"
fi fi
# Decompress the qpress files
# Decompress the qpress files
wsrep_log_info "Decompression with $nproc threads" wsrep_log_info "Decompression with $nproc threads"
timeit "Joiner-Decompression" "find ${DATA} -type f -name '*.qp' -printf '%p\n%h\n' | $dcmd" timeit "Joiner-Decompression" "find ${DATA} -type f -name '*.qp' -printf '%p\n%h\n' | $dcmd"
extcode=$? extcode=$?
if [[ $extcode -eq 0 ]];then if [[ $extcode -eq 0 ]];then
wsrep_log_info "Removing qpress files after decompression" wsrep_log_info "Removing qpress files after decompression"
find ${DATA} -type f -name '*.qp' -delete find ${DATA} -type f -name '*.qp' -delete
if [[ $? -ne 0 ]];then if [[ $? -ne 0 ]];then
wsrep_log_error "Something went wrong with deletion of qpress files. Investigate" wsrep_log_error "Something went wrong with deletion of qpress files. Investigate"
fi fi
else else
...@@ -1235,13 +1213,12 @@ then ...@@ -1235,13 +1213,12 @@ then
fi fi
fi fi
if [[ ! -z $WSREP_SST_OPT_BINLOG ]];then if [[ ! -z $WSREP_SST_OPT_BINLOG ]];then
BINLOG_DIRNAME=$(dirname $WSREP_SST_OPT_BINLOG) BINLOG_DIRNAME=$(dirname $WSREP_SST_OPT_BINLOG)
BINLOG_FILENAME=$(basename $WSREP_SST_OPT_BINLOG) BINLOG_FILENAME=$(basename $WSREP_SST_OPT_BINLOG)
# To avoid comparing data directory and BINLOG_DIRNAME # To avoid comparing data directory and BINLOG_DIRNAME
mv $DATA/${BINLOG_FILENAME}.* $BINLOG_DIRNAME/ 2>/dev/null || true mv $DATA/${BINLOG_FILENAME}.* $BINLOG_DIRNAME/ 2>/dev/null || true
pushd $BINLOG_DIRNAME &>/dev/null pushd $BINLOG_DIRNAME &>/dev/null
...@@ -1257,7 +1234,7 @@ then ...@@ -1257,7 +1234,7 @@ then
if [ $? -ne 0 ]; if [ $? -ne 0 ];
then then
wsrep_log_error "${INNOBACKUPEX_BIN} apply finished with errors. Check ${DATA}/innobackup.prepare.log" wsrep_log_error "${INNOBACKUPEX_BIN} apply finished with errors. Check ${DATA}/innobackup.prepare.log"
exit 22 exit 22
fi fi
...@@ -1267,22 +1244,21 @@ then ...@@ -1267,22 +1244,21 @@ then
set -e set -e
wsrep_log_info "Moving the backup to ${TDATA}" wsrep_log_info "Moving the backup to ${TDATA}"
timeit "Xtrabackup move stage" "$INNOMOVE" timeit "Xtrabackup move stage" "$INNOMOVE"
if [[ $? -eq 0 ]];then if [[ $? -eq 0 ]];then
wsrep_log_info "Move successful, removing ${DATA}" wsrep_log_info "Move successful, removing ${DATA}"
rm -rf $DATA rm -rf $DATA
DATA=${TDATA} DATA=${TDATA}
else else
wsrep_log_error "Move failed, keeping ${DATA} for further diagnosis" wsrep_log_error "Move failed, keeping ${DATA} for further diagnosis"
wsrep_log_error "Check ${DATA}/innobackup.move.log for details" wsrep_log_error "Check ${DATA}/innobackup.move.log for details"
exit 22 exit 22
fi fi
else
else
wsrep_log_info "${IST_FILE} received from donor: Running IST" wsrep_log_info "${IST_FILE} received from donor: Running IST"
fi fi
if [[ ! -r ${MAGIC_FILE} ]];then if [[ ! -r ${MAGIC_FILE} ]];then
wsrep_log_error "SST magic file ${MAGIC_FILE} not found/readable" wsrep_log_error "SST magic file ${MAGIC_FILE} not found/readable"
exit 2 exit 2
fi fi
......
...@@ -15,12 +15,9 @@ ...@@ -15,12 +15,9 @@
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston
# MA 02110-1335 USA. # MA 02110-1335 USA.
# Optional dependencies and options documented here: http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html # Optional dependencies and options documented here: http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html
# Make sure to read that before proceeding! # Make sure to read that before proceeding!
. $(dirname $0)/wsrep_sst_common . $(dirname $0)/wsrep_sst_common
ealgo="" ealgo=""
...@@ -52,7 +49,7 @@ pvformat="-F '%N => Rate:%r Avg:%a Elapsed:%t %e Bytes: %b %p' " ...@@ -52,7 +49,7 @@ pvformat="-F '%N => Rate:%r Avg:%a Elapsed:%t %e Bytes: %b %p' "
pvopts="-f -i 10 -N $WSREP_SST_OPT_ROLE " pvopts="-f -i 10 -N $WSREP_SST_OPT_ROLE "
uextra=0 uextra=0
if which pv &>/dev/null && pv --help | grep -q FORMAT;then if which pv &>/dev/null && pv --help | grep -q FORMAT;then
pvopts+=$pvformat pvopts+=$pvformat
fi fi
pcmd="pv $pvopts" pcmd="pv $pvopts"
...@@ -73,7 +70,7 @@ timeit(){ ...@@ -73,7 +70,7 @@ timeit(){
local cmd="$@" local cmd="$@"
local x1 x2 took extcode local x1 x2 took extcode
if [[ $ttime -eq 1 ]];then if [[ $ttime -eq 1 ]];then
x1=$(date +%s) x1=$(date +%s)
wsrep_log_info "Evaluating $cmd" wsrep_log_info "Evaluating $cmd"
eval "$cmd" eval "$cmd"
...@@ -82,7 +79,7 @@ timeit(){ ...@@ -82,7 +79,7 @@ timeit(){
took=$(( x2-x1 )) took=$(( x2-x1 ))
wsrep_log_info "NOTE: $stage took $took seconds" wsrep_log_info "NOTE: $stage took $took seconds"
totime=$(( totime+took )) totime=$(( totime+took ))
else else
wsrep_log_info "Evaluating $cmd" wsrep_log_info "Evaluating $cmd"
eval "$cmd" eval "$cmd"
extcode=$? extcode=$?
...@@ -92,11 +89,11 @@ timeit(){ ...@@ -92,11 +89,11 @@ timeit(){
get_keys() get_keys()
{ {
if [[ $encrypt -eq 2 ]];then if [[ $encrypt -eq 2 ]];then
return return
fi fi
if [[ $encrypt -eq 0 ]];then if [[ $encrypt -eq 0 ]];then
if $MY_PRINT_DEFAULTS xtrabackup | grep -q encrypt;then if $MY_PRINT_DEFAULTS xtrabackup | grep -q encrypt;then
wsrep_log_error "Unexpected option combination. SST may fail. Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html " wsrep_log_error "Unexpected option combination. SST may fail. Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html "
fi fi
...@@ -137,13 +134,13 @@ get_transfer() ...@@ -137,13 +134,13 @@ get_transfer()
TSST_PORT=${WSREP_SST_OPT_PORT:-4444} TSST_PORT=${WSREP_SST_OPT_PORT:-4444}
if [[ $tfmt == 'nc' ]];then if [[ $tfmt == 'nc' ]];then
if [[ ! -x `which nc` ]];then if [[ ! -x `which nc` ]];then
wsrep_log_error "nc(netcat) not found in path: $PATH" wsrep_log_error "nc(netcat) not found in path: $PATH"
exit 2 exit 2
fi fi
wsrep_log_info "Using netcat as streamer" wsrep_log_info "Using netcat as streamer"
if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
if nc -h 2>&1 | grep -q ncat;then if nc -h 2>&1 | grep -q ncat;then
# Ncat # Ncat
tcmd="nc -l ${TSST_PORT}" tcmd="nc -l ${TSST_PORT}"
elif nc -h 2>&1 | grep -q -- '-d\>';then elif nc -h 2>&1 | grep -q -- '-d\>';then
...@@ -168,19 +165,19 @@ get_transfer() ...@@ -168,19 +165,19 @@ get_transfer()
else else
tfmt='socat' tfmt='socat'
wsrep_log_info "Using socat as streamer" wsrep_log_info "Using socat as streamer"
if [[ ! -x `which socat` ]];then if [[ ! -x `which socat` ]];then
wsrep_log_error "socat not found in path: $PATH" wsrep_log_error "socat not found in path: $PATH"
exit 2 exit 2
fi fi
if [[ $encrypt -eq 2 ]] && ! socat -V | grep -q OPENSSL;then if [[ $encrypt -eq 2 ]] && ! socat -V | grep -q OPENSSL;then
wsrep_log_info "NOTE: socat is not openssl enabled, falling back to plain transfer" wsrep_log_info "NOTE: socat is not openssl enabled, falling back to plain transfer"
encrypt=0 encrypt=0
fi fi
if [[ $encrypt -eq 2 ]];then if [[ $encrypt -eq 2 ]];then
wsrep_log_info "Using openssl based encryption with socat" wsrep_log_info "Using openssl based encryption with socat"
if [[ -z $tpem || -z $tcert ]];then if [[ -z $tpem || -z $tcert ]];then
wsrep_log_error "Both PEM and CRT files required" wsrep_log_error "Both PEM and CRT files required"
exit 22 exit 22
fi fi
...@@ -191,7 +188,7 @@ get_transfer() ...@@ -191,7 +188,7 @@ get_transfer()
wsrep_log_info "Encrypting with PEM $tpem, CA: $tcert" wsrep_log_info "Encrypting with PEM $tpem, CA: $tcert"
tcmd="socat -u stdio openssl-connect:${WSREP_SST_OPT_HOST}:${TSST_PORT},cert=$tpem,cafile=${tcert}${sockopt}" tcmd="socat -u stdio openssl-connect:${WSREP_SST_OPT_HOST}:${TSST_PORT},cert=$tpem,cafile=${tcert}${sockopt}"
fi fi
else else
if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
tcmd="socat -u TCP-LISTEN:${TSST_PORT},reuseaddr${sockopt} stdio" tcmd="socat -u TCP-LISTEN:${TSST_PORT},reuseaddr${sockopt} stdio"
else else
...@@ -199,14 +196,13 @@ get_transfer() ...@@ -199,14 +196,13 @@ get_transfer()
fi fi
fi fi
fi fi
} }
get_footprint() get_footprint()
{ {
pushd $WSREP_SST_OPT_DATA 1>/dev/null pushd $WSREP_SST_OPT_DATA 1>/dev/null
payload=$(find . -regex '.*\.ibd$\|.*\.MYI$\|.*\.MYD$\|.*ibdata1$' -type f -print0 | du --files0-from=- --block-size=1 -c -s | awk 'END { print $1 }') payload=$(find . -regex '.*\.ibd$\|.*\.MYI$\|.*\.MYD$\|.*ibdata1$' -type f -print0 | du --files0-from=- --block-size=1 -c -s | awk 'END { print $1 }')
if $MY_PRINT_DEFAULTS xtrabackup | grep -q -- "--compress";then if $MY_PRINT_DEFAULTS xtrabackup | grep -q -- "--compress";then
# QuickLZ has around 50% compression ratio # QuickLZ has around 50% compression ratio
# When compression/compaction used, the progress is only an approximate. # When compression/compaction used, the progress is only an approximate.
payload=$(( payload*1/2 )) payload=$(( payload*1/2 ))
...@@ -218,16 +214,16 @@ get_footprint() ...@@ -218,16 +214,16 @@ get_footprint()
adjust_progress() adjust_progress()
{ {
if [[ -n $progress && $progress != '1' ]];then if [[ -n $progress && $progress != '1' ]];then
if [[ -e $progress ]];then if [[ -e $progress ]];then
pcmd+=" 2>>$progress" pcmd+=" 2>>$progress"
else else
pcmd+=" 2>$progress" pcmd+=" 2>$progress"
fi fi
elif [[ -z $progress && -n $rlimit ]];then elif [[ -z $progress && -n $rlimit ]];then
# When rlimit is non-zero # When rlimit is non-zero
pcmd="pv -q" pcmd="pv -q"
fi fi
if [[ -n $rlimit && "$WSREP_SST_OPT_ROLE" == "donor" ]];then if [[ -n $rlimit && "$WSREP_SST_OPT_ROLE" == "donor" ]];then
wsrep_log_info "Rate-limiting SST to $rlimit" wsrep_log_info "Rate-limiting SST to $rlimit"
...@@ -251,7 +247,7 @@ read_cnf() ...@@ -251,7 +247,7 @@ read_cnf()
ekey=$(parse_cnf xtrabackup encrypt-key "") ekey=$(parse_cnf xtrabackup encrypt-key "")
ekeyfile=$(parse_cnf xtrabackup encrypt-key-file "") ekeyfile=$(parse_cnf xtrabackup encrypt-key-file "")
# Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html # Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html
if [[ -z $ealgo ]];then if [[ -z $ealgo ]];then
ealgo=$(parse_cnf sst encrypt-algo "") ealgo=$(parse_cnf sst encrypt-algo "")
ekey=$(parse_cnf sst encrypt-key "") ekey=$(parse_cnf sst encrypt-key "")
...@@ -263,7 +259,7 @@ read_cnf() ...@@ -263,7 +259,7 @@ read_cnf()
get_stream() get_stream()
{ {
if [[ $sfmt == 'xbstream' ]];then if [[ $sfmt == 'xbstream' ]];then
wsrep_log_info "Streaming with xbstream" wsrep_log_info "Streaming with xbstream"
if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
strmcmd="xbstream -x" strmcmd="xbstream -x"
...@@ -278,7 +274,6 @@ get_stream() ...@@ -278,7 +274,6 @@ get_stream()
else else
strmcmd="tar cf - \${INFO_FILE} \${IST_FILE}" strmcmd="tar cf - \${INFO_FILE} \${IST_FILE}"
fi fi
fi fi
} }
...@@ -300,14 +295,14 @@ cleanup_joiner() ...@@ -300,14 +295,14 @@ cleanup_joiner()
{ {
# Since this is invoked just after exit NNN # Since this is invoked just after exit NNN
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"
fi fi
if [ "${WSREP_SST_OPT_ROLE}" = "joiner" ];then if [ "${WSREP_SST_OPT_ROLE}" = "joiner" ];then
wsrep_log_info "Removing the sst_in_progress file" wsrep_log_info "Removing the sst_in_progress file"
wsrep_cleanup_progress_file wsrep_cleanup_progress_file
fi fi
if [[ -n $progress && -p $progress ]];then if [[ -n $progress && -p $progress ]];then
wsrep_log_info "Cleaning up fifo file $progress" wsrep_log_info "Cleaning up fifo file $progress"
rm $progress rm $progress
fi fi
...@@ -323,22 +318,22 @@ cleanup_donor() ...@@ -323,22 +318,22 @@ cleanup_donor()
{ {
# Since this is invoked just after exit NNN # Since this is invoked just after exit NNN
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"
fi fi
if [[ -n $XTRABACKUP_PID ]];then if [[ -n $XTRABACKUP_PID ]];then
if check_pid $XTRABACKUP_PID if check_pid $XTRABACKUP_PID
then then
wsrep_log_error "xtrabackup process is still running. Killing... " wsrep_log_error "xtrabackup process is still running. Killing... "
kill_xtrabackup kill_xtrabackup
fi fi
rm -f $XTRABACKUP_PID
rm -f $XTRABACKUP_PID
fi fi
rm -f ${DATA}/${IST_FILE} rm -f ${DATA}/${IST_FILE}
if [[ -n $progress && -p $progress ]];then if [[ -n $progress && -p $progress ]];then
wsrep_log_info "Cleaning up fifo file $progress" wsrep_log_info "Cleaning up fifo file $progress"
rm $progress rm $progress
fi fi
...@@ -363,9 +358,9 @@ wait_for_listen() ...@@ -363,9 +358,9 @@ wait_for_listen()
ss -p state listening "( sport = :$PORT )" | grep -qE 'socat|nc' && break ss -p state listening "( sport = :$PORT )" | grep -qE 'socat|nc' && break
sleep 0.2 sleep 0.2
done done
if [[ $incremental -eq 1 ]];then if [[ $incremental -eq 1 ]];then
echo "ready ${ADDR}/${MODULE}/$lsn" echo "ready ${ADDR}/${MODULE}/$lsn"
else else
echo "ready ${ADDR}/${MODULE}" echo "ready ${ADDR}/${MODULE}"
fi fi
} }
...@@ -373,20 +368,20 @@ wait_for_listen() ...@@ -373,20 +368,20 @@ wait_for_listen()
check_extra() check_extra()
{ {
local use_socket=1 local use_socket=1
if [[ $uextra -eq 1 ]];then if [[ $uextra -eq 1 ]];then
if [ $(parse_cnf --mysqld thread-handling) = 'pool-of-threads'];then if [ $(parse_cnf --mysqld thread-handling) = 'pool-of-threads'];then
local eport=$(parse_cnf --mysqld extra-port) local eport=$(parse_cnf --mysqld extra-port)
if [[ -n $eport ]];then if [[ -n $eport ]];then
# Xtrabackup works only locally. # Xtrabackup works only locally.
# Hence, setting host to 127.0.0.1 unconditionally. # Hence, setting host to 127.0.0.1 unconditionally.
wsrep_log_info "SST through extra_port $eport" wsrep_log_info "SST through extra_port $eport"
INNOEXTRA+=" --host=127.0.0.1 --port=$eport" INNOEXTRA+=" --host=127.0.0.1 --port=$eport"
use_socket=0 use_socket=0
else else
wsrep_log_error "Extra port $eport null, failing" wsrep_log_error "Extra port $eport null, failing"
exit 1 exit 1
fi fi
else else
wsrep_log_info "Thread pool not set, ignore the option use_extra" wsrep_log_info "Thread pool not set, ignore the option use_extra"
fi fi
fi fi
...@@ -395,14 +390,14 @@ check_extra() ...@@ -395,14 +390,14 @@ check_extra()
fi fi
} }
if [[ ! -x `which innobackupex` ]];then if [[ ! -x `which innobackupex` ]];then
wsrep_log_error "innobackupex not in path: $PATH" wsrep_log_error "innobackupex not in path: $PATH"
exit 2 exit 2
fi fi
rm -f "${MAGIC_FILE}" rm -f "${MAGIC_FILE}"
if [[ ! ${WSREP_SST_OPT_ROLE} == 'joiner' && ! ${WSREP_SST_OPT_ROLE} == 'donor' ]];then if [[ ! ${WSREP_SST_OPT_ROLE} == 'joiner' && ! ${WSREP_SST_OPT_ROLE} == 'donor' ]];then
wsrep_log_error "Invalid role ${WSREP_SST_OPT_ROLE}" wsrep_log_error "Invalid role ${WSREP_SST_OPT_ROLE}"
exit 22 exit 22
fi fi
...@@ -440,12 +435,12 @@ then ...@@ -440,12 +435,12 @@ then
if [[ $encrypt -eq 1 ]];then if [[ $encrypt -eq 1 ]];then
if [[ -n $ekey ]];then if [[ -n $ekey ]];then
INNOEXTRA+=" --encrypt=$ealgo --encrypt-key=$ekey" INNOEXTRA+=" --encrypt=$ealgo --encrypt-key=$ekey"
else else
INNOEXTRA+=" --encrypt=$ealgo --encrypt-key-file=$ekeyfile" INNOEXTRA+=" --encrypt=$ealgo --encrypt-key-file=$ekeyfile"
fi fi
fi fi
if [[ -n $lsn ]];then if [[ -n $lsn ]];then
INNOEXTRA+=" --incremental --incremental-lsn=$lsn" INNOEXTRA+=" --incremental --incremental-lsn=$lsn"
fi fi
...@@ -453,10 +448,10 @@ then ...@@ -453,10 +448,10 @@ then
wsrep_log_info "Streaming the backup to joiner at ${WSREP_SST_OPT_HOST} ${WSREP_SST_OPT_PORT}" wsrep_log_info "Streaming the backup to joiner at ${WSREP_SST_OPT_HOST} ${WSREP_SST_OPT_PORT}"
if [[ -n $progress ]];then if [[ -n $progress ]];then
get_footprint get_footprint
tcmd="$pcmd | $tcmd" tcmd="$pcmd | $tcmd"
elif [[ -n $rlimit ]];then elif [[ -n $rlimit ]];then
adjust_progress adjust_progress
tcmd="$pcmd | $tcmd" tcmd="$pcmd | $tcmd"
fi fi
...@@ -469,7 +464,7 @@ then ...@@ -469,7 +464,7 @@ then
wsrep_log_error "${INNOBACKUPEX_BIN} finished with error: ${RC[0]}. " \ wsrep_log_error "${INNOBACKUPEX_BIN} finished with error: ${RC[0]}. " \
"Check ${DATA}/innobackup.backup.log" "Check ${DATA}/innobackup.backup.log"
exit 22 exit 22
elif [[ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ]];then elif [[ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ]];then
wsrep_log_error "$tcmd finished with error: ${RC[1]}" wsrep_log_error "$tcmd finished with error: ${RC[1]}"
exit 22 exit 22
fi fi
...@@ -496,13 +491,14 @@ then ...@@ -496,13 +491,14 @@ then
set -e set -e
popd 1>/dev/null popd 1>/dev/null
for ecode in "${RC[@]}";do for ecode in "${RC[@]}";do
if [[ $ecode -ne 0 ]];then if [[ $ecode -ne 0 ]];then
wsrep_log_error "Error while streaming data to joiner node: " \ wsrep_log_error "Error while streaming data to joiner node: " \
"exit codes: ${RC[@]}" "exit codes: ${RC[@]}"
exit 1 exit 1
fi fi
done done
fi fi
echo "done ${WSREP_SST_OPT_GTID}" echo "done ${WSREP_SST_OPT_GTID}"
...@@ -513,11 +509,11 @@ then ...@@ -513,11 +509,11 @@ then
[[ -e $SST_PROGRESS_FILE ]] && wsrep_log_info "Stale sst_in_progress file: $SST_PROGRESS_FILE" [[ -e $SST_PROGRESS_FILE ]] && wsrep_log_info "Stale sst_in_progress file: $SST_PROGRESS_FILE"
touch $SST_PROGRESS_FILE touch $SST_PROGRESS_FILE
if [[ ! -e ${DATA}/ibdata1 ]];then if [[ ! -e ${DATA}/ibdata1 ]];then
incremental=0 incremental=0
fi fi
if [[ $incremental -eq 1 ]];then if [[ $incremental -eq 1 ]];then
wsrep_log_info "Incremental SST enabled" wsrep_log_info "Incremental SST enabled"
#lsn=$(/pxc/bin/mysqld $WSREP_SST_OPT_CONF --basedir=/pxc --wsrep-recover 2>&1 | grep -o 'log sequence number .*' | cut -d " " -f 4 | head -1) #lsn=$(/pxc/bin/mysqld $WSREP_SST_OPT_CONF --basedir=/pxc --wsrep-recover 2>&1 | grep -o 'log sequence number .*' | cut -d " " -f 4 | head -1)
lsn=$(grep to_lsn xtrabackup_checkpoints | cut -d= -f2 | tr -d ' ') lsn=$(grep to_lsn xtrabackup_checkpoints | cut -d= -f2 | tr -d ' ')
...@@ -539,12 +535,12 @@ then ...@@ -539,12 +535,12 @@ then
trap sig_joiner_cleanup HUP PIPE INT TERM trap sig_joiner_cleanup HUP PIPE INT TERM
trap cleanup_joiner EXIT trap cleanup_joiner EXIT
if [[ -n $progress ]];then if [[ -n $progress ]];then
adjust_progress adjust_progress
tcmd+=" | $pcmd" tcmd+=" | $pcmd"
fi fi
if [[ $incremental -eq 1 ]];then if [[ $incremental -eq 1 ]];then
BDATA=$DATA BDATA=$DATA
DATA=$(mktemp -d) DATA=$(mktemp -d)
MAGIC_FILE="${DATA}/${INFO_FILE}" MAGIC_FILE="${DATA}/${INFO_FILE}"
...@@ -558,13 +554,13 @@ then ...@@ -558,13 +554,13 @@ then
pushd ${DATA} 1>/dev/null pushd ${DATA} 1>/dev/null
timeit "Joiner-Recv-Unencrypted" "$tcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )" timeit "Joiner-Recv-Unencrypted" "$tcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
popd 1>/dev/null popd 1>/dev/null
set -e set -e
if [[ $sfmt == 'xbstream' ]];then if [[ $sfmt == 'xbstream' ]];then
# Special handling till lp:1193240 is fixed" # Special handling till lp:1193240 is fixed"
if [[ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ]];then if [[ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ]];then
wsrep_log_error "Xbstream failed" wsrep_log_error "Xbstream failed"
wsrep_log_error "Data directory ${DATA} may not be empty: lp:1193240" \ wsrep_log_error "Data directory ${DATA} may not be empty: lp:1193240" \
"Manual intervention required in that case" "Manual intervention required in that case"
...@@ -574,8 +570,8 @@ then ...@@ -574,8 +570,8 @@ then
wait %% # join for wait_for_listen thread wait %% # join for wait_for_listen thread
for ecode in "${RC[@]}";do for ecode in "${RC[@]}";do
if [[ $ecode -ne 0 ]];then if [[ $ecode -ne 0 ]];then
wsrep_log_error "Error while getting data from donor node: " \ wsrep_log_error "Error while getting data from donor node: " \
"exit codes: ${RC[@]}" "exit codes: ${RC[@]}"
exit 32 exit 32
...@@ -586,22 +582,23 @@ then ...@@ -586,22 +582,23 @@ then
then then
# this message should cause joiner to abort # this message should cause joiner to abort
wsrep_log_error "xtrabackup process ended without creating '${MAGIC_FILE}'" wsrep_log_error "xtrabackup process ended without creating '${MAGIC_FILE}'"
wsrep_log_info "Contents of datadir" wsrep_log_info "Contents of datadir"
wsrep_log_info "$(ls -l ${DATA}/**/*)" wsrep_log_info "$(ls -l ${DATA}/**/*)"
exit 32 exit 32
fi fi
if ! ps -p ${WSREP_SST_OPT_PARENT} &>/dev/null if ! ps -p ${WSREP_SST_OPT_PARENT} &>/dev/null
then then
wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly." wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly."
exit 32 exit 32
fi fi
if [ ! -r "${DATA}/${IST_FILE}" ] if [ ! -r "${DATA}/${IST_FILE}" ]
then then
wsrep_log_info "Proceeding with SST" wsrep_log_info "Proceeding with SST"
wsrep_log_info "Removing existing ib_logfile files" wsrep_log_info "Removing existing ib_logfile files"
if [[ $incremental -ne 1 ]];then if [[ $incremental -ne 1 ]];then
rm -f ${DATA}/ib_logfile* rm -f ${DATA}/ib_logfile*
else else
rm -f ${BDATA}/ib_logfile* rm -f ${BDATA}/ib_logfile*
...@@ -610,12 +607,12 @@ then ...@@ -610,12 +607,12 @@ then
get_proc get_proc
# Rebuild indexes for compact backups # Rebuild indexes for compact backups
if grep -q 'compact = 1' ${DATA}/xtrabackup_checkpoints;then if grep -q 'compact = 1' ${DATA}/xtrabackup_checkpoints;then
wsrep_log_info "Index compaction detected" wsrep_log_info "Index compaction detected"
rebuild=1 rebuild=1
fi fi
if [[ $rebuild -eq 1 ]];then if [[ $rebuild -eq 1 ]];then
nthreads=$(parse_cnf xtrabackup rebuild-threads $nproc) nthreads=$(parse_cnf xtrabackup rebuild-threads $nproc)
wsrep_log_info "Rebuilding during prepare with $nthreads threads" wsrep_log_info "Rebuilding during prepare with $nthreads threads"
rebuildcmd="--rebuild-indexes --rebuild-threads=$nthreads" rebuildcmd="--rebuild-indexes --rebuild-threads=$nthreads"
...@@ -625,7 +622,7 @@ then ...@@ -625,7 +622,7 @@ then
wsrep_log_info "Compressed qpress files found" wsrep_log_info "Compressed qpress files found"
if [[ ! -x `which qpress` ]];then if [[ ! -x `which qpress` ]];then
wsrep_log_error "qpress not found in path: $PATH" wsrep_log_error "qpress not found in path: $PATH"
exit 22 exit 22
fi fi
...@@ -633,30 +630,30 @@ then ...@@ -633,30 +630,30 @@ then
if [[ -n $progress ]] && pv --help | grep -q 'line-mode';then if [[ -n $progress ]] && pv --help | grep -q 'line-mode';then
count=$(find ${DATA} -type f -name '*.qp' | wc -l) count=$(find ${DATA} -type f -name '*.qp' | wc -l)
count=$(( count*2 )) count=$(( count*2 ))
if pv --help | grep -q FORMAT;then if pv --help | grep -q FORMAT;then
pvopts="-f -s $count -l -N Decompression -F '%N => Rate:%r Elapsed:%t %e Progress: [%b/$count]'" pvopts="-f -s $count -l -N Decompression -F '%N => Rate:%r Elapsed:%t %e Progress: [%b/$count]'"
else else
pvopts="-f -s $count -l -N Decompression" pvopts="-f -s $count -l -N Decompression"
fi fi
pcmd="pv $pvopts" pcmd="pv $pvopts"
adjust_progress adjust_progress
dcmd="$pcmd | xargs -n 2 qpress -T${nproc}d" dcmd="$pcmd | xargs -n 2 qpress -T${nproc}d"
else else
dcmd="xargs -n 2 qpress -T${nproc}d" dcmd="xargs -n 2 qpress -T${nproc}d"
fi fi
wsrep_log_info "Removing existing ibdata1 file" wsrep_log_info "Removing existing ibdata1 file"
rm -f ${DATA}/ibdata1 rm -f ${DATA}/ibdata1
# Decompress the qpress files # Decompress the qpress files
wsrep_log_info "Decompression with $nproc threads" wsrep_log_info "Decompression with $nproc threads"
timeit "Decompression" "find ${DATA} -type f -name '*.qp' -printf '%p\n%h\n' | $dcmd" timeit "Decompression" "find ${DATA} -type f -name '*.qp' -printf '%p\n%h\n' | $dcmd"
extcode=$? extcode=$?
if [[ $extcode -eq 0 ]];then if [[ $extcode -eq 0 ]];then
wsrep_log_info "Removing qpress files after decompression" wsrep_log_info "Removing qpress files after decompression"
find ${DATA} -type f -name '*.qp' -delete find ${DATA} -type f -name '*.qp' -delete
if [[ $? -ne 0 ]];then if [[ $? -ne 0 ]];then
wsrep_log_error "Something went wrong with deletion of qpress files. Investigate" wsrep_log_error "Something went wrong with deletion of qpress files. Investigate"
fi fi
else else
...@@ -665,7 +662,7 @@ then ...@@ -665,7 +662,7 @@ then
fi fi
fi fi
if [[ $incremental -eq 1 ]];then if [[ $incremental -eq 1 ]];then
# Added --ibbackup=xtrabackup_55 because it fails otherwise citing connection issues. # Added --ibbackup=xtrabackup_55 because it fails otherwise citing connection issues.
INNOAPPLY="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} \ INNOAPPLY="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} \
--ibbackup=xtrabackup_55 --apply-log $rebuildcmd --redo-only $BDATA --incremental-dir=${DATA} &>>${BDATA}/innobackup.prepare.log" --ibbackup=xtrabackup_55 --apply-log $rebuildcmd --redo-only $BDATA --incremental-dir=${DATA} &>>${BDATA}/innobackup.prepare.log"
...@@ -674,7 +671,7 @@ then ...@@ -674,7 +671,7 @@ then
wsrep_log_info "Preparing the backup at ${DATA}" wsrep_log_info "Preparing the backup at ${DATA}"
timeit "Xtrabackup prepare stage" "$INNOAPPLY" timeit "Xtrabackup prepare stage" "$INNOAPPLY"
if [[ $incremental -eq 1 ]];then if [[ $incremental -eq 1 ]];then
wsrep_log_info "Cleaning up ${DATA} after incremental SST" wsrep_log_info "Cleaning up ${DATA} after incremental SST"
[[ -d ${DATA} ]] && rm -rf ${DATA} [[ -d ${DATA} ]] && rm -rf ${DATA}
DATA=$BDATA DATA=$BDATA
...@@ -682,10 +679,10 @@ then ...@@ -682,10 +679,10 @@ then
if [ $? -ne 0 ]; if [ $? -ne 0 ];
then then
wsrep_log_error "${INNOBACKUPEX_BIN} finished with errors. Check ${DATA}/innobackup.prepare.log" wsrep_log_error "${INNOBACKUPEX_BIN} finished with errors. Check ${DATA}/innobackup.prepare.log"
exit 22 exit 22
fi fi
else else
wsrep_log_info "${IST_FILE} received from donor: Running IST" wsrep_log_info "${IST_FILE} received from donor: Running IST"
fi fi
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment