summaryrefslogtreecommitdiff
path: root/scripts/wsrep_sst_mariabackup.sh
diff options
context:
space:
mode:
authorJulius Goryavsky <julius.goryavsky@mariadb.com>2020-10-13 13:33:47 +0200
committerJulius Goryavsky <julius.goryavsky@mariadb.com>2020-10-15 13:49:22 +0200
commit31201dcbaf0f35a4fccb83855c1e1157f9532b31 (patch)
treed6be2e4ce6734d986bd4b5aef1ef4f6fea9433d9 /scripts/wsrep_sst_mariabackup.sh
parent24c5af6758091dd4d9513e385ac76618c64ba0d2 (diff)
downloadmariadb-git-31201dcbaf0f35a4fccb83855c1e1157f9532b31.tar.gz
MDEV-21770: `galera_3nodes.galera_ipv6_mariabackup` fails
This patch fixes several flaws in the SST scripts that cause failures while running tests that use version 6 IP addresses for cluster nodes. First, if the netcat utility is used for streaming (but not socat), then in accordance with its command line syntax, we need to remove the square brackets around the IPv6 address. However, for socat, the address must contain square brackets, as before. Secondly, if an IPv6 address is used, then from the joiner side for a number of systems (such as Debian) we need to explicitly specify the "-6" option, otherwise a listening socket with an IPv6 address may not be created. This patch also contains code improvements in the wsrep_sst_common. Changed the code that pars the connection address - fixed the shortcomings that sometimes led to incorrect parsing of parameters when using shells other than the latest versions of bash. Also, this patch removes the duplicate code that is intended for parsing the connection address and which was located in the wsrep_sst_mariabackup file, since all the necessary actions have already been done in wsrep_sst_common and there they are done in such a way that any shell is supported, not just bash. The fix does not require separate tests, since all the necessary tests are already present in the galera_3nodes suite. On the contrary, after this fix, tests using IPv6 addresses can be removed from the disabled list (this will be done in a separate commit related to MDEV-23659).
Diffstat (limited to 'scripts/wsrep_sst_mariabackup.sh')
-rw-r--r--scripts/wsrep_sst_mariabackup.sh63
1 files changed, 35 insertions, 28 deletions
diff --git a/scripts/wsrep_sst_mariabackup.sh b/scripts/wsrep_sst_mariabackup.sh
index ef2a3b66de8..85138c3c0be 100644
--- a/scripts/wsrep_sst_mariabackup.sh
+++ b/scripts/wsrep_sst_mariabackup.sh
@@ -189,27 +189,48 @@ get_transfer()
if nc -h 2>&1 | grep -q ncat;then
# Ncat
tcmd="nc -l ${TSST_PORT}"
- elif nc -h 2>&1 | grep -q -- '-d\>';then
+ elif nc -h 2>&1 | grep -qw -- '-d\>';then
# Debian netcat
- tcmd="nc -dl ${TSST_PORT}"
+ if [ $WSREP_SST_OPT_HOST_IPv6 -eq 1 ];then
+ # When host is not explicitly specified (when only the port
+ # is specified) netcat can only bind to an IPv4 address if
+ # the "-6" option is not explicitly specified:
+ tcmd="nc -dl -6 ${TSST_PORT}"
+ else
+ tcmd="nc -dl ${TSST_PORT}"
+ fi
else
# traditional netcat
tcmd="nc -l -p ${TSST_PORT}"
fi
else
+ # Check to see if netcat supports the '-N' flag.
+ # -N Shutdown the network socket after EOF on stdin
+ # If it supports the '-N' flag, then we need to use the '-N'
+ # flag, otherwise the transfer will stay open after the file
+ # transfer and cause the command to timeout.
+ # Older versions of netcat did not need this flag and will
+ # return an error if the flag is used.
+ #
+ tcmd_extra=""
+ if nc -h 2>&1 | grep -qw -- -N; then
+ tcmd_extra+="-N"
+ wsrep_log_info "Using nc -N"
+ fi
+
+ # netcat doesn't understand [] around IPv6 address
if nc -h 2>&1 | grep -q ncat;then
# Ncat
- tcmd="nc ${REMOTEIP} ${TSST_PORT}"
- elif nc -h 2>&1 | grep -q -- '-d\>';then
+ wsrep_log_info "Using Ncat as streamer"
+ tcmd="nc ${tcmd_extra} ${WSREP_SST_OPT_HOST_UNESCAPED} ${TSST_PORT}"
+ elif nc -h 2>&1 | grep -qw -- '-d\>';then
# Debian netcat
- if nc -h 2>&1 | grep -q -- '-N\>';then
- tcmd="nc -N ${REMOTEIP} ${TSST_PORT}"
- else
- tcmd="nc ${REMOTEIP} ${TSST_PORT}"
- fi
+ wsrep_log_info "Using Debian netcat as streamer"
+ tcmd="nc ${tcmd_extra} ${WSREP_SST_OPT_HOST_UNESCAPED} ${TSST_PORT}"
else
# traditional netcat
- tcmd="nc -q0 ${REMOTEIP} ${TSST_PORT}"
+ wsrep_log_info "Using traditional netcat as streamer"
+ tcmd="nc -q0 ${tcmd_extra} ${WSREP_SST_OPT_HOST_UNESCAPED} ${TSST_PORT}"
fi
fi
else
@@ -527,25 +548,11 @@ kill_xtrabackup()
setup_ports()
{
+ SST_PORT=${WSREP_SST_OPT_ADDR_PORT}
if [[ "$WSREP_SST_OPT_ROLE" == "donor" ]];then
- if [ "${WSREP_SST_OPT_ADDR#\[}" != "$WSREP_SST_OPT_ADDR" ]; then
- remain=$(echo $WSREP_SST_OPT_ADDR | awk -F '\\][:/]' '{ print $2 }')
- REMOTEIP=$(echo $WSREP_SST_OPT_ADDR | awk -F '\\]:' '{ print $1 }')"]"
- SST_PORT=$(echo $remain | awk -F '[:/]' '{ print $1 }')
- lsn=$(echo $remain | awk -F '[:/]' '{ print $3 }')
- sst_ver=$(echo $remain | awk -F '[:/]' '{ print $4 }')
- else
- SST_PORT=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $2 }')
- REMOTEIP=$(echo $WSREP_SST_OPT_ADDR | awk -F ':' '{ print $1 }')
- lsn=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $4 }')
- sst_ver=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $5 }')
- fi
- else
- if [ "${WSREP_SST_OPT_ADDR#\[}" != "$WSREP_SST_OPT_ADDR" ]; then
- SST_PORT=$(echo ${WSREP_SST_OPT_ADDR} | awk -F '\\]:' '{ print $2 }')
- else
- SST_PORT=$(echo ${WSREP_SST_OPT_ADDR} | awk -F ':' '{ print $2 }')
- fi
+ REMOTEIP=${WSREP_SST_OPT_HOST}
+ lsn=${WSREP_SST_OPT_LSN}
+ sst_ver=${WSREP_SST_OPT_SST_VER}
fi
}