From 2c5d8376cdfd25d7510c85b3896b506715f96590 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Wed, 7 Aug 2024 16:40:35 +0200 Subject: [PATCH] MDEV-30686: Endless loop when trying to establish connection With wsrep_sst_rsync, node goes into endless loop when trying to establish connection to donor for IST/SST if the database is bind on specific IP address, not the "*". This commit fixes this problem. Separate tests are not required - the problem can occur in normal configurations on a number of systems when selecting a bing address other than "*", especially on FreeBSD and with the IPv6 addresses. --- scripts/wsrep_sst_rsync.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index e386930c5b7..b05f4bc2efd 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -100,10 +100,9 @@ check_pid_and_port() local busy=0 if [ $lsof_available -ne 0 ]; then - port_info=$(lsof -Pnl -i ":$port" 2>/dev/null | \ - grep -F '(LISTEN)') + port_info=$(lsof -Pnl -i ":$port" 2>/dev/null | grep -F '(LISTEN)') echo "$port_info" | \ - grep -q -E "[[:space:]](\\*|\\[?::\\]?):$port[[:space:]]" && busy=1 + grep -q -E "[[:space:]]\\[?(\\*|[[:xdigit:]]*(:[[:xdigit:]]*)+)(\\](%[^:]+)?)?:$port[[:space:]]" && busy=1 else local filter='([^[:space:]]+[[:space:]]+){4}[^[:space:]]+' if [ $sockstat_available -ne 0 ]; then @@ -122,7 +121,7 @@ check_pid_and_port() grep -F 'users:(' | grep -o -E "$filter") fi echo "$port_info" | \ - grep -q -E "[[:space:]](\\*|\\[?::\\]?):$port\$" && busy=1 + grep -q -E "[[:space:]]\\[?(\\*|[[:xdigit:]]*(:[[:xdigit:]]*)+)(\\](%[^:]+)?)?:$port\$" && busy=1 fi if [ $busy -eq 0 ]; then