Blame SOURCES/wsrep_sst_rsync_tunnel

a41a5b
#!/bin/bash -ue
a41a5b
a41a5b
# Copyright (C) 2010-2014 Codership Oy
a41a5b
# Copyright (C) 2017 Damien Ciabrini <damien.ciabrini@gmail.com>
a41a5b
#
a41a5b
# This program is free software; you can redistribute it and/or modify
a41a5b
# it under the terms of the GNU General Public License as published by
a41a5b
# the Free Software Foundation; version 2 of the License.
a41a5b
#
a41a5b
# This program is distributed in the hope that it will be useful,
a41a5b
# but WITHOUT ANY WARRANTY; without even the implied warranty of
a41a5b
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a41a5b
# GNU General Public License for more details.
a41a5b
#
a41a5b
# You should have received a copy of the GNU General Public License
a41a5b
# along with this program; see the file COPYING. If not, write to the
a41a5b
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston
a41a5b
# MA  02110-1301  USA.
a41a5b
a41a5b
# This is a reference script for rsync-based state snapshot tansfer
a41a5b
# over an encrypted communication channel, managed by socat
a41a5b
a41a5b
RSYNC_PID=                                      # rsync pid file
a41a5b
RSYNC_CONF=                                     # rsync configuration file
a41a5b
RSYNC_REAL_PID=                                 # rsync process id
a41a5b
a41a5b
SOCAT_PID=                                      # socat pid file
a41a5b
SOCAT_REAL_PID=                                 # socat process id
a41a5b
a41a5b
SOCAT_OPTS=                                     # openssl connection args
a41a5b
a41a5b
MODULE="rsync_tunnel_sst"
a41a5b
a41a5b
OS=$(uname)
a41a5b
[ "$OS" == "Darwin" ] && export -n LD_LIBRARY_PATH
a41a5b
a41a5b
# Setting the path for lsof on CentOS
a41a5b
export PATH="/usr/sbin:/sbin:$PATH"
a41a5b
a41a5b
. $(dirname $0)/wsrep_sst_common
a41a5b
a41a5b
wsrep_check_programs rsync socat
a41a5b
a41a5b
cleanup_pid()
a41a5b
{
a41a5b
    local real_pid=$1
a41a5b
    [ "0" != "$real_pid" ]            && \
a41a5b
    kill $real_pid                    && \
a41a5b
    sleep 0.5                         && \
a41a5b
    kill -9 $real_pid >/dev/null 2>&1 || \
a41a5b
    :
a41a5b
}
a41a5b
a41a5b
cleanup_tunnel()
a41a5b
{
a41a5b
    wsrep_log_info "cleanup socat PID: $SOCAT_REAL_PID"
a41a5b
    [ -n "$SOCAT_REAL_PID" ] && cleanup_pid $SOCAT_REAL_PID
a41a5b
    rm -rf "$SOCAT_PID"
a41a5b
}
a41a5b
a41a5b
cleanup_joiner()
a41a5b
{
a41a5b
    wsrep_log_info "Joiner cleanup. rsync PID: $RSYNC_REAL_PID"
a41a5b
    [ -n "$RSYNC_REAL_PID" ] && cleanup_pid $RSYNC_REAL_PID
a41a5b
    rm -rf "$RSYNC_CONF"
a41a5b
    rm -rf "$MAGIC_FILE"
a41a5b
    rm -rf "$RSYNC_PID"
a41a5b
a41a5b
    cleanup_tunnel
a41a5b
a41a5b
    wsrep_log_info "Joiner cleanup done."
a41a5b
    if [ "${WSREP_SST_OPT_ROLE}" = "joiner" ];then
a41a5b
        wsrep_cleanup_progress_file
a41a5b
    fi
a41a5b
}
a41a5b
a41a5b
# Check whether process is still running.
a41a5b
check_pid()
a41a5b
{
a41a5b
    local pid_file=$1
a41a5b
    [ -r "$pid_file" ] && ps -p $(cat $pid_file) >/dev/null 2>&1
a41a5b
}
a41a5b
a41a5b
check_pid_and_port()
a41a5b
{
a41a5b
    local pid_file=$1
a41a5b
    local service_pid=$2
a41a5b
    local service_port=$3
a41a5b
    local service_host=$4
a41a5b
    local service_name=$5
a41a5b
a41a5b
    if ! which lsof > /dev/null; then
a41a5b
      wsrep_log_error "lsof tool not found in PATH! Make sure you have it installed."
a41a5b
      exit 2 # ENOENT
a41a5b
    fi
a41a5b
a41a5b
    local port_info=$(lsof -i "@"$service_host:$service_port -Pn 2>/dev/null | \
a41a5b
        grep "(LISTEN)")
a41a5b
    local is_service=$(echo $port_info | \
a41a5b
        grep -w '^'"$service_name"'[[:space:]]\+'"$service_pid" 2>/dev/null)
a41a5b
a41a5b
    if [ -n "$port_info" -a -z "$is_service" ]; then
a41a5b
        wsrep_log_error "$service_name daemon port '$service_port' has been taken"
a41a5b
        exit 16 # EBUSY
a41a5b
    fi
a41a5b
a41a5b
    if ! check_pid $pid_file; then
a41a5b
        wsrep_log_error "$service_name process terminated unexpectedly"
a41a5b
        exit 10 # ECHILD
a41a5b
    fi
a41a5b
a41a5b
    [ -n "$port_info" ] && [ -n "$is_service" ] && \
a41a5b
        [ $(cat $pid_file) -eq $service_pid ]
a41a5b
}
a41a5b
a41a5b
config_from_cnf()
a41a5b
{
a41a5b
    local group=$1
a41a5b
    local key=$2
a41a5b
    echo $($MY_PRINT_DEFAULTS $group | grep -- "--$key=" | cut -d= -f2- | tail -1)
a41a5b
}
a41a5b
a41a5b
setup_tunnel_args()
a41a5b
{
a41a5b
    tca=$(config_from_cnf sst tca)
a41a5b
    tkey=$(config_from_cnf sst tkey)
a41a5b
    tcert=$(config_from_cnf sst tcert)
a41a5b
    sockopt=$(config_from_cnf sst sockopt)
a41a5b
a41a5b
    if [ -z "$tcert" ]; then
a41a5b
        wsrep_log_error "Encryption certificate not found in my.cnf"
a41a5b
        exit 3
a41a5b
    else
a41a5b
        SOCAT_OPTS="cert=$tcert"
a41a5b
    fi
a41a5b
    [ -n "$tkey" ] && SOCAT_OPTS="$SOCAT_OPTS,key=$tkey"
a41a5b
    [ -n "$tca" ] && SOCAT_OPTS="$SOCAT_OPTS,cafile=$tca"
a41a5b
    wsrep_log_info "Encryption setting to be used for socat tunnel: $SOCAT_OPTS"
a41a5b
a41a5b
    [ -n "$sockopt" ] && SOCAT_OPTS="$SOCAT_OPTS,$sockopt"
a41a5b
}
a41a5b
a41a5b
MAGIC_FILE="$WSREP_SST_OPT_DATA/rsync_tunnel_sst_complete"
a41a5b
rm -rf "$MAGIC_FILE"
a41a5b
a41a5b
BINLOG_TAR_FILE="$WSREP_SST_OPT_DATA/wsrep_sst_binlog.tar"
a41a5b
BINLOG_N_FILES=1
a41a5b
rm -f "$BINLOG_TAR_FILE" || :
a41a5b
a41a5b
if ! [ -z $WSREP_SST_OPT_BINLOG ]
a41a5b
then
a41a5b
    BINLOG_DIRNAME=$(dirname $WSREP_SST_OPT_BINLOG)
a41a5b
    BINLOG_FILENAME=$(basename $WSREP_SST_OPT_BINLOG)
a41a5b
fi
a41a5b
a41a5b
WSREP_LOG_DIR=${WSREP_LOG_DIR:-""}
a41a5b
# if WSREP_LOG_DIR env. variable is not set, try to get it from my.cnf
a41a5b
if [ -z "$WSREP_LOG_DIR" ]; then
a41a5b
    WSREP_LOG_DIR=$($MY_PRINT_DEFAULTS --mysqld \
a41a5b
                    | grep -- '--innodb[-_]log[-_]group[-_]home[-_]dir=' \
a41a5b
                    | cut -b 29- )
a41a5b
fi
a41a5b
a41a5b
if [ -n "$WSREP_LOG_DIR" ]; then
a41a5b
    # handle both relative and absolute paths
a41a5b
    WSREP_LOG_DIR=$(cd $WSREP_SST_OPT_DATA; mkdir -p "$WSREP_LOG_DIR"; cd $WSREP_LOG_DIR; pwd -P)
a41a5b
else
a41a5b
    # default to datadir
a41a5b
    WSREP_LOG_DIR=$(cd $WSREP_SST_OPT_DATA; pwd -P)
a41a5b
fi
a41a5b
a41a5b
# Old filter - include everything except selected
a41a5b
# FILTER=(--exclude '*.err' --exclude '*.pid' --exclude '*.sock' \
a41a5b
#         --exclude '*.conf' --exclude core --exclude 'galera.*' \
a41a5b
#         --exclude grastate.txt --exclude '*.pem' \
a41a5b
#         --exclude '*.[0-9][0-9][0-9][0-9][0-9][0-9]' --exclude '*.index')
a41a5b
a41a5b
# New filter - exclude everything except dirs (schemas) and innodb files
a41a5b
FILTER=(-f '- /lost+found' -f '- /.fseventsd' -f '- /.Trashes'
a41a5b
        -f '+ /wsrep_sst_binlog.tar' -f '+ /ib_lru_dump' -f '+ /ibdata*' -f '+ /*/' -f '- /*')
a41a5b
a41a5b
SOCAT_PID="$WSREP_SST_OPT_DATA/$MODULE-socat.pid"
a41a5b
a41a5b
if check_pid $SOCAT_PID
a41a5b
then
a41a5b
    wsrep_log_error "socat tunnel already running."
a41a5b
    exit 114 # EALREADY
a41a5b
fi
a41a5b
rm -rf "$SOCAT_PID"
a41a5b
a41a5b
setup_tunnel_args
a41a5b
a41a5b
if [ "$WSREP_SST_OPT_ROLE" = "donor" ]
a41a5b
then
a41a5b
a41a5b
    SOCAT_JOINER_ADDR=$(echo $WSREP_SST_OPT_ADDR | awk -F'/' '{print $1}')
a41a5b
    # map to name in case we received an IP
a41a5b
    SOCAT_JOINER_HOST=$(getent hosts $SOCAT_JOINER_ADDR | awk '{ print $2 }')
a41a5b
    if [ -z "$SOCAT_JOINER_HOST" ]; then
a41a5b
        SOCAT_JOINER_HOST=$SOCAT_JOINER_ADDR
a41a5b
    fi
a41a5b
    SOCAT_PORT=$(echo $SOCAT_JOINER_ADDR | awk -F ':' '{ print $2 }')
a41a5b
    if [ -z "$SOCAT_PORT" ]
a41a5b
    then
a41a5b
        SOCAT_PORT=4444
a41a5b
    fi
a41a5b
    TARGET_ADDR=localhost:$SOCAT_PORT/$MODULE
a41a5b
a41a5b
    trap cleanup_tunnel EXIT
a41a5b
a41a5b
    # Socat forwards rsync connections to the joiner
a41a5b
    SOCAT_SRC=tcp-listen:$SOCAT_PORT,bind=localhost,reuseaddr,fork
a41a5b
    SOCAT_DST=openssl:$SOCAT_JOINER_HOST,$SOCAT_OPTS
a41a5b
    wsrep_log_info "Setting up tunnel for donor: socat $SOCAT_SRC $SOCAT_DST"
a41a5b
    socat $SOCAT_SRC $SOCAT_DST &
a41a5b
    SOCAT_REAL_PID=$!
a41a5b
    # This is ok because a local galera node doesn't run SST concurrently
a41a5b
    echo $SOCAT_REAL_PID >"$SOCAT_PID"
a41a5b
    until check_pid_and_port $SOCAT_PID $SOCAT_REAL_PID $SOCAT_PORT localhost "socat"
a41a5b
    do
a41a5b
        sleep 0.2
a41a5b
    done
a41a5b
a41a5b
    if [ $WSREP_SST_OPT_BYPASS -eq 0 ]
a41a5b
    then
a41a5b
a41a5b
        FLUSHED="$WSREP_SST_OPT_DATA/tables_flushed"
a41a5b
        ERROR="$WSREP_SST_OPT_DATA/sst_error"
a41a5b
a41a5b
        rm -rf "$FLUSHED"
a41a5b
        rm -rf "$ERROR"
a41a5b
a41a5b
        # Use deltaxfer only for WAN
a41a5b
        inv=$(basename $0)
a41a5b
        [ "$inv" = "wsrep_sst_rsync_wan" ] && WHOLE_FILE_OPT="" \
a41a5b
                                           || WHOLE_FILE_OPT="--whole-file"
a41a5b
a41a5b
        echo "flush tables"
a41a5b
a41a5b
        # Wait for :
a41a5b
        # (a) Tables to be flushed, AND
a41a5b
        # (b) Cluster state ID & wsrep_gtid_domain_id to be written to the file, OR
a41a5b
        # (c) ERROR file, in case flush tables operation failed.
a41a5b
a41a5b
        while [ ! -r "$FLUSHED" ] && ! grep -q ':' "$FLUSHED" >/dev/null 2>&1
a41a5b
        do
a41a5b
            # Check whether ERROR file exists.
a41a5b
            if [ -f "$ERROR" ]
a41a5b
            then
a41a5b
                # Flush tables operation failed.
a41a5b
                rm -rf "$ERROR"
a41a5b
                exit 255
a41a5b
            fi
a41a5b
a41a5b
            sleep 0.2
a41a5b
        done
a41a5b
a41a5b
        STATE="$(cat $FLUSHED)"
a41a5b
        rm -rf "$FLUSHED"
a41a5b
a41a5b
        sync
a41a5b
a41a5b
        if ! [ -z $WSREP_SST_OPT_BINLOG ]
a41a5b
        then
a41a5b
            # Prepare binlog files
a41a5b
            pushd $BINLOG_DIRNAME &> /dev/null
a41a5b
            binlog_files_full=$(tail -n $BINLOG_N_FILES ${BINLOG_FILENAME}.index)
a41a5b
            binlog_files=""
a41a5b
            for ii in $binlog_files_full
a41a5b
            do
a41a5b
                binlog_files="$binlog_files $(basename $ii)"
a41a5b
            done
a41a5b
            if ! [ -z "$binlog_files" ]
a41a5b
            then
a41a5b
                wsrep_log_info "Preparing binlog files for transfer:"
a41a5b
                tar -cvf $BINLOG_TAR_FILE $binlog_files >&2
a41a5b
            fi
a41a5b
            popd &> /dev/null
a41a5b
        fi
a41a5b
a41a5b
        # first, the normal directories, so that we can detect incompatible protocol
a41a5b
        RC=0
a41a5b
        rsync --owner --group --perms --links --specials \
a41a5b
              --ignore-times --inplace --dirs --delete --quiet \
a41a5b
              $WHOLE_FILE_OPT "${FILTER[@]}" "$WSREP_SST_OPT_DATA/" \
a41a5b
              rsync://$TARGET_ADDR >&2 || RC=$?
a41a5b
a41a5b
        if [ "$RC" -ne 0 ]; then
a41a5b
            wsrep_log_error "rsync returned code $RC:"
a41a5b
a41a5b
            case $RC in
a41a5b
            12) RC=71  # EPROTO
a41a5b
                wsrep_log_error \
a41a5b
                "rsync server on the other end has incompatible protocol. " \
a41a5b
                "Make sure you have the same version of rsync on all nodes."
a41a5b
                ;;
a41a5b
            22) RC=12  # ENOMEM
a41a5b
                ;;
a41a5b
            *)  RC=255 # unknown error
a41a5b
                ;;
a41a5b
            esac
a41a5b
            exit $RC
a41a5b
        fi
a41a5b
a41a5b
        # second, we transfer InnoDB log files
a41a5b
        rsync --owner --group --perms --links --specials \
a41a5b
              --ignore-times --inplace --dirs --delete --quiet \
a41a5b
              $WHOLE_FILE_OPT -f '+ /ib_logfile[0-9]*' -f '- **' "$WSREP_LOG_DIR/" \
a41a5b
              rsync://$TARGET_ADDR-log_dir >&2 || RC=$?
a41a5b
a41a5b
        if [ $RC -ne 0 ]; then
a41a5b
            wsrep_log_error "rsync innodb_log_group_home_dir returned code $RC:"
a41a5b
            exit 255 # unknown error
a41a5b
        fi
a41a5b
a41a5b
        # then, we parallelize the transfer of database directories, use . so that pathconcatenation works
a41a5b
        pushd "$WSREP_SST_OPT_DATA" >/dev/null
a41a5b
a41a5b
        count=1
a41a5b
        [ "$OS" == "Linux" ] && count=$(grep -c processor /proc/cpuinfo)
a41a5b
        [ "$OS" == "Darwin" -o "$OS" == "FreeBSD" ] && count=$(sysctl -n hw.ncpu)
a41a5b
a41a5b
        find . -maxdepth 1 -mindepth 1 -type d -not -name "lost+found" -print0 | \
a41a5b
             xargs -I{} -0 -P $count \
a41a5b
             rsync --owner --group --perms --links --specials \
a41a5b
             --ignore-times --inplace --recursive --delete --quiet \
a41a5b
             $WHOLE_FILE_OPT --exclude '*/ib_logfile*' "$WSREP_SST_OPT_DATA"/{}/ \
a41a5b
             rsync://$TARGET_ADDR/{} >&2 || RC=$?
a41a5b
a41a5b
        popd >/dev/null
a41a5b
a41a5b
        if [ $RC -ne 0 ]; then
a41a5b
            wsrep_log_error "find/rsync returned code $RC:"
a41a5b
            exit 255 # unknown error
a41a5b
        fi
a41a5b
a41a5b
    else # BYPASS
a41a5b
        wsrep_log_info "Bypassing state dump."
a41a5b
a41a5b
        # Store donor's wsrep GTID (state ID) and wsrep_gtid_domain_id
a41a5b
        # (separated by a space).
a41a5b
        STATE="$WSREP_SST_OPT_GTID $WSREP_SST_OPT_GTID_DOMAIN_ID"
a41a5b
    fi
a41a5b
a41a5b
    echo "continue" # now server can resume updating data
a41a5b
a41a5b
    echo "$STATE" > "$MAGIC_FILE"
a41a5b
    rsync --archive --quiet --checksum "$MAGIC_FILE" rsync://$TARGET_ADDR
a41a5b
a41a5b
    echo "done $STATE"
a41a5b
a41a5b
elif [ "$WSREP_SST_OPT_ROLE" = "joiner" ]
a41a5b
then
a41a5b
    wsrep_check_programs lsof socat
a41a5b
a41a5b
    touch $SST_PROGRESS_FILE
a41a5b
    MYSQLD_PID=$WSREP_SST_OPT_PARENT
a41a5b
a41a5b
    RSYNC_PID="$WSREP_SST_OPT_DATA/$MODULE.pid"
a41a5b
a41a5b
    if check_pid $RSYNC_PID
a41a5b
    then
a41a5b
        wsrep_log_error "rsync daemon already running."
a41a5b
        exit 114 # EALREADY
a41a5b
    fi
a41a5b
    rm -rf "$RSYNC_PID"
a41a5b
a41a5b
    ADDR=$WSREP_SST_OPT_ADDR
a41a5b
    RSYNC_PORT=$(echo $ADDR | awk -F ':' '{ print $2 }')
a41a5b
    if [ -z "$RSYNC_PORT" ]
a41a5b
    then
a41a5b
        RSYNC_PORT=4444
a41a5b
        ADDR="$(echo $ADDR | awk -F ':' '{ print $1 }'):$RSYNC_PORT"
a41a5b
    fi
a41a5b
a41a5b
    SOCAT_ADDR=$(echo $ADDR | awk -F ':' '{ print $1 }')
a41a5b
    # map to name in case we received an IP
a41a5b
    SOCAT_HOST=$(getent hosts $SOCAT_ADDR | awk '{ print $2 }')
a41a5b
    if [ -z "$SOCAT_HOST" ]; then
a41a5b
        SOCAT_HOST=$SOCAT_ADDR
a41a5b
    fi
a41a5b
    SOCAT_PORT=$RSYNC_PORT
a41a5b
a41a5b
    trap "exit 32" HUP PIPE
a41a5b
    trap "exit 3"  INT TERM ABRT
a41a5b
    trap cleanup_joiner EXIT
a41a5b
a41a5b
    RSYNC_CONF="$WSREP_SST_OPT_DATA/$MODULE.conf"
a41a5b
a41a5b
    if [ -n "${MYSQL_TMP_DIR:-}" ] ; then
a41a5b
      SILENT="log file = $MYSQL_TMP_DIR/rsynd.log"
a41a5b
    else
a41a5b
      SILENT=""
a41a5b
    fi
a41a5b
a41a5b
cat << EOF > "$RSYNC_CONF"
a41a5b
pid file = $RSYNC_PID
a41a5b
use chroot = no
a41a5b
read only = no
a41a5b
timeout = 300
a41a5b
$SILENT
a41a5b
[$MODULE]
a41a5b
    path = $WSREP_SST_OPT_DATA
a41a5b
[$MODULE-log_dir]
a41a5b
    path = $WSREP_LOG_DIR
a41a5b
EOF
a41a5b
a41a5b
#    rm -rf "$DATA"/ib_logfile* # we don't want old logs around
a41a5b
a41a5b
    # Socat receives rsync connections from the donor
a41a5b
    SOCAT_SRC=openssl-listen:$SOCAT_PORT,bind=$SOCAT_HOST,reuseaddr,fork,$SOCAT_OPTS
a41a5b
    SOCAT_DST=tcp:localhost:$RSYNC_PORT
a41a5b
    wsrep_log_info "Setting up tunnel for joiner: socat $SOCAT_SRC $SOCAT_DST"
a41a5b
    socat $SOCAT_SRC $SOCAT_DST &
a41a5b
    SOCAT_REAL_PID=$!
a41a5b
    # This is ok because a local galera node doesn't run SST concurrently
a41a5b
    echo $SOCAT_REAL_PID >"$SOCAT_PID"
a41a5b
    until check_pid_and_port $SOCAT_PID $SOCAT_REAL_PID $SOCAT_PORT $SOCAT_HOST "socat"
a41a5b
    do
a41a5b
        sleep 0.2
a41a5b
    done
a41a5b
a41a5b
    wsrep_log_info "rsync --daemon --no-detach --address localhost --port $RSYNC_PORT --config \"$RSYNC_CONF\""
a41a5b
    rsync --daemon --no-detach --address localhost --port $RSYNC_PORT --config "$RSYNC_CONF" &
a41a5b
    RSYNC_REAL_PID=$!
a41a5b
a41a5b
    until check_pid_and_port $RSYNC_PID $RSYNC_REAL_PID $RSYNC_PORT localhost "rsync"
a41a5b
    do
a41a5b
        sleep 0.2
a41a5b
    done
a41a5b
a41a5b
    echo "ready $ADDR/$MODULE"
a41a5b
a41a5b
    # wait for SST to complete by monitoring magic file
a41a5b
    while [ ! -r "$MAGIC_FILE" ] && check_pid "$RSYNC_PID" && \
a41a5b
          check_pid "$SOCAT_PID" && ps -p $MYSQLD_PID >/dev/null
a41a5b
    do
a41a5b
        sleep 1
a41a5b
    done
a41a5b
a41a5b
    if ! ps -p $MYSQLD_PID >/dev/null
a41a5b
    then
a41a5b
        wsrep_log_error \
a41a5b
        "Parent mysqld process (PID:$MYSQLD_PID) terminated unexpectedly."
a41a5b
        exit 32
a41a5b
    fi
a41a5b
a41a5b
    if ! [ -z $WSREP_SST_OPT_BINLOG ]
a41a5b
    then
a41a5b
a41a5b
        pushd $BINLOG_DIRNAME &> /dev/null
a41a5b
        if [ -f $BINLOG_TAR_FILE ]
a41a5b
        then
a41a5b
            # Clean up old binlog files first
a41a5b
            rm -f ${BINLOG_FILENAME}.*
a41a5b
            wsrep_log_info "Extracting binlog files:"
a41a5b
            tar -xvf $BINLOG_TAR_FILE >&2
a41a5b
            for ii in $(ls -1 ${BINLOG_FILENAME}.*)
a41a5b
            do
a41a5b
                echo ${BINLOG_DIRNAME}/${ii} >> ${BINLOG_FILENAME}.index
a41a5b
            done
a41a5b
        fi
a41a5b
        popd &> /dev/null
a41a5b
    fi
a41a5b
    if [ -r "$MAGIC_FILE" ]
a41a5b
    then
a41a5b
        # UUID:seqno & wsrep_gtid_domain_id is received here.
a41a5b
        cat "$MAGIC_FILE" # Output : UUID:seqno wsrep_gtid_domain_id
a41a5b
    else
a41a5b
        # this message should cause joiner to abort
a41a5b
        echo "rsync process ended without creating '$MAGIC_FILE'"
a41a5b
    fi
a41a5b
    wsrep_cleanup_progress_file
a41a5b
#    cleanup_joiner
a41a5b
else
a41a5b
    wsrep_log_error "Unrecognized role: '$WSREP_SST_OPT_ROLE'"
a41a5b
    exit 22 # EINVAL
a41a5b
fi
a41a5b
a41a5b
rm -f $BINLOG_TAR_FILE || :
a41a5b
a41a5b
exit 0