Commit de0f93fb authored by Julius Goryavsky's avatar Julius Goryavsky

MDEV-20420: SST failed after MDEV-18863 in some test configurations

After applying MDEV-18863, in some test configurations, SST
may fails due to duplication of some parameters (in particular
"--port") in the main part of the command line and after
"--mysqld-args", as well as due to incorrect interpretation
of the parameter "--port" passed after "--mysqld-args" when
the SST script is invoked without explicitly specifying a port
for SST. In addition, it is necessary to correctly handle spaces,
quotation marks and special characters when copying original
arguments from the argv[] array to a new command line (after
"--mysqld-args"). This patch resolves these shortcomings.
parent 4a9fb905
...@@ -166,7 +166,11 @@ case "$1" in ...@@ -166,7 +166,11 @@ case "$1" in
shift shift
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
option=${1%%=*} option=${1%%=*}
if [ "$option" != "--defaults-file" ]; then if [[ "$option" != "--defaults-file" && \
"$option" != "--defaults-extra-file" && \
"$option" != "--defaults-group-suffix" && \
"$option" != "--port" && \
"$option" != "--socket" ]]; then
value=${1#*=} value=${1#*=}
case "$option" in case "$option" in
'--innodb-data-home-dir') '--innodb-data-home-dir')
...@@ -249,7 +253,15 @@ else ...@@ -249,7 +253,15 @@ else
MY_PRINT_DEFAULTS=$(which my_print_defaults) MY_PRINT_DEFAULTS=$(which my_print_defaults)
fi fi
readonly WSREP_SST_OPT_CONF="$WSREP_SST_OPT_DEFAULT $WSREP_SST_OPT_EXTRA_DEFAULT $WSREP_SST_OPT_SUFFIX_DEFAULT" wsrep_defaults="$WSREP_SST_OPT_DEFAULT"
if [ -n "$wsrep_defaults" ]; then
wsrep_defaults="$wsrep_defaults "
fi
wsrep_defaults="$wsrep_defaults$WSREP_SST_OPT_EXTRA_DEFAULT"
if [ -n "$wsrep_defaults" ]; then
wsrep_defaults="$wsrep_defaults "
fi
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"
wsrep_auth_not_set() wsrep_auth_not_set()
......
...@@ -60,7 +60,7 @@ rebuild=0 ...@@ -60,7 +60,7 @@ rebuild=0
rebuildcmd="" rebuildcmd=""
payload=0 payload=0
pvformat="-F '%N => Rate:%r Avg:%a Elapsed:%t %e Bytes: %b %p' " 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 "
STATDIR="" STATDIR=""
uextra=0 uextra=0
disver="" disver=""
...@@ -130,7 +130,7 @@ get_keys() ...@@ -130,7 +130,7 @@ get_keys()
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
return return
fi fi
...@@ -465,7 +465,7 @@ cleanup_donor() ...@@ -465,7 +465,7 @@ cleanup_donor()
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
...@@ -567,7 +567,7 @@ check_extra() ...@@ -567,7 +567,7 @@ check_extra()
# 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"
...@@ -577,8 +577,8 @@ check_extra() ...@@ -577,8 +577,8 @@ check_extra()
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
if [[ $use_socket -eq 1 ]] && [[ -n "${WSREP_SST_OPT_SOCKET}" ]];then if [[ $use_socket -eq 1 ]] && [[ -n "$WSREP_SST_OPT_SOCKET" ]];then
INNOEXTRA+=" --socket=${WSREP_SST_OPT_SOCKET}" INNOEXTRA+=" --socket=$WSREP_SST_OPT_SOCKET"
fi fi
} }
...@@ -745,8 +745,8 @@ if [[ $ssyslog -eq 1 ]];then ...@@ -745,8 +745,8 @@ if [[ $ssyslog -eq 1 ]];then
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} --innobackupex $disver $iapts \$INNOEXTRA --apply-log \$rebuildcmd \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-apply " INNOAPPLY="${INNOBACKUPEX_BIN} --innobackupex $disver $iapts \$INNOEXTRA --apply-log \$rebuildcmd \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-apply"
INNOMOVE="${INNOBACKUPEX_BIN} --innobackupex ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-move " INNOMOVE="${INNOBACKUPEX_BIN} --innobackupex ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-move"
INNOBACKUP="${INNOBACKUPEX_BIN} --innobackupex ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2> >(logger -p daemon.err -t ${ssystag}innobackupex-backup)" INNOBACKUP="${INNOBACKUPEX_BIN} --innobackupex ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2> >(logger -p daemon.err -t ${ssystag}innobackupex-backup)"
fi fi
...@@ -856,13 +856,12 @@ then ...@@ -856,13 +856,12 @@ then
get_keys get_keys
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
check_extra check_extra
wsrep_log_info "Streaming GTID file before SST" wsrep_log_info "Streaming GTID file before SST"
...@@ -883,7 +882,6 @@ then ...@@ -883,7 +882,6 @@ then
tcmd=" $scomp | $tcmd " tcmd=" $scomp | $tcmd "
fi fi
send_donor $DATA "${stagemsg}-gtid" send_donor $DATA "${stagemsg}-gtid"
tcmd="$ttcmd" tcmd="$ttcmd"
......
...@@ -23,7 +23,7 @@ RSYNC_CONF= # rsync configuration file ...@@ -23,7 +23,7 @@ RSYNC_CONF= # rsync configuration file
RSYNC_REAL_PID= # rsync process id RSYNC_REAL_PID= # rsync process id
OS=$(uname) OS=$(uname)
[ "$OS" == "Darwin" ] && export -n LD_LIBRARY_PATH [ "$OS" = "Darwin" ] && export -n LD_LIBRARY_PATH
# Setting the path for lsof on CentOS # Setting the path for lsof on CentOS
export PATH="/usr/sbin:/sbin:$PATH" export PATH="/usr/sbin:/sbin:$PATH"
...@@ -69,11 +69,6 @@ check_pid_and_port() ...@@ -69,11 +69,6 @@ check_pid_and_port()
exit 2 # ENOENT exit 2 # ENOENT
fi fi
if ! which lsof > /dev/null; then
wsrep_log_error "lsof tool not found in PATH! Make sure you have it installed."
exit 2 # ENOENT
fi
local port_info=$(lsof -i :$rsync_port -Pn 2>/dev/null | \ local port_info=$(lsof -i :$rsync_port -Pn 2>/dev/null | \
grep "(LISTEN)") grep "(LISTEN)")
local is_rsync=$(echo $port_info | \ local is_rsync=$(echo $port_info | \
...@@ -318,8 +313,8 @@ EOF ...@@ -318,8 +313,8 @@ EOF
cd $WSREP_SST_OPT_DATA cd $WSREP_SST_OPT_DATA
count=1 count=1
[ "$OS" == "Linux" ] && count=$(grep -c processor /proc/cpuinfo) [ "$OS" = "Linux" ] && count=$(grep -c processor /proc/cpuinfo)
[ "$OS" == "Darwin" -o "$OS" == "FreeBSD" ] && count=$(sysctl -n hw.ncpu) [ "$OS" = "Darwin" -o "$OS" = "FreeBSD" ] && count=$(sysctl -n hw.ncpu)
find . -maxdepth 1 -mindepth 1 -type d -not -name "lost+found" \ find . -maxdepth 1 -mindepth 1 -type d -not -name "lost+found" \
-print0 | xargs -I{} -0 -P $count \ -print0 | xargs -I{} -0 -P $count \
...@@ -439,7 +434,7 @@ EOF ...@@ -439,7 +434,7 @@ EOF
RSYNC_PID=$STUNNEL_PID RSYNC_PID=$STUNNEL_PID
fi fi
until check_pid_and_port $RSYNC_PID $RSYNC_REAL_PID $RSYNC_PORT until check_pid_and_port "$RSYNC_PID" "$RSYNC_REAL_PID" "$RSYNC_PORT"
do do
sleep 0.2 sleep 0.2
done done
......
...@@ -56,7 +56,7 @@ rebuild=0 ...@@ -56,7 +56,7 @@ rebuild=0
rebuildcmd="" rebuildcmd=""
payload=0 payload=0
pvformat="-F '%N => Rate:%r Avg:%a Elapsed:%t %e Bytes: %b %p' " 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 "
STATDIR="" STATDIR=""
uextra=0 uextra=0
disver="" disver=""
...@@ -675,7 +675,7 @@ check_extra() ...@@ -675,7 +675,7 @@ check_extra()
# 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"
...@@ -685,8 +685,8 @@ check_extra() ...@@ -685,8 +685,8 @@ check_extra()
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
if [[ $use_socket -eq 1 ]] && [[ -n "${WSREP_SST_OPT_SOCKET}" ]];then if [[ $use_socket -eq 1 ]] && [[ -n "$WSREP_SST_OPT_SOCKET" ]];then
INNOEXTRA+=" --socket=${WSREP_SST_OPT_SOCKET}" INNOEXTRA+=" --socket=$WSREP_SST_OPT_SOCKET"
fi fi
} }
......
...@@ -49,7 +49,7 @@ rebuild=0 ...@@ -49,7 +49,7 @@ rebuild=0
rebuildcmd="" rebuildcmd=""
payload=0 payload=0
pvformat="-F '%N => Rate:%r Avg:%a Elapsed:%t %e Bytes: %b %p' " 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
...@@ -380,7 +380,7 @@ check_extra() ...@@ -380,7 +380,7 @@ check_extra()
# 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"
...@@ -390,8 +390,8 @@ check_extra() ...@@ -390,8 +390,8 @@ check_extra()
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
if [[ $use_socket -eq 1 ]] && [[ -n "${WSREP_SST_OPT_SOCKET}" ]];then if [[ $use_socket -eq 1 ]] && [[ -n "$WSREP_SST_OPT_SOCKET" ]];then
INNOEXTRA+=" --socket=${WSREP_SST_OPT_SOCKET}" INNOEXTRA+=" --socket=$WSREP_SST_OPT_SOCKET"
fi fi
} }
...@@ -439,14 +439,14 @@ then ...@@ -439,14 +439,14 @@ then
get_keys get_keys
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
check_extra check_extra
......
This diff is collapsed.
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