View | Details | Raw Unified | Return to bug 229618 | Differences between
and this patch

Collapse All | Expand All

(-)scripts/wsrep_sst_mariabackup.sh (-126 / +164 lines)
Lines 1-4 Link Here
1
#!/usr/local/bin/bash -ue
1
#!/bin/sh -ue
2
# Copyright (C) 2013 Percona Inc
2
# Copyright (C) 2013 Percona Inc
3
# Copyright (C) 2017 MariaDB
3
# Copyright (C) 2017 MariaDB
4
#
4
#
Lines 101-107 timeit(){ Link Here
101
    local cmd="$@"
101
    local cmd="$@"
102
    local x1 x2 took extcode
102
    local x1 x2 took extcode
103
103
104
    if [[ $ttime -eq 1 ]];then 
104
    if [ $ttime -eq 1 ];then 
105
        x1=$(date +%s)
105
        x1=$(date +%s)
106
        wsrep_log_info "Evaluating $cmd"
106
        wsrep_log_info "Evaluating $cmd"
107
        eval "$cmd"
107
        eval "$cmd"
Lines 121-138 timeit(){ Link Here
121
get_keys()
121
get_keys()
122
{
122
{
123
    # $encrypt -eq 1 is for internal purposes only
123
    # $encrypt -eq 1 is for internal purposes only
124
    if [[ $encrypt -ge 2 || $encrypt -eq -1 ]];then 
124
    if [ $encrypt -ge 2 -o $encrypt -eq -1 ];then 
125
        return 
125
        return 
126
    fi
126
    fi
127
127
128
    if [[ $encrypt -eq 0 ]];then 
128
    if [ $encrypt -eq 0 ];then 
129
        if $MY_PRINT_DEFAULTS xtrabackup | grep -q encrypt;then
129
        if $MY_PRINT_DEFAULTS xtrabackup | grep -q encrypt;then
130
            wsrep_log_error "Unexpected option combination. SST may fail. Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html "
130
            wsrep_log_error "Unexpected option combination. SST may fail. Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html "
131
        fi
131
        fi
132
        return
132
        return
133
    fi
133
    fi
134
134
135
    if [[ $sfmt == 'tar' ]];then
135
    if [ "$sfmt" = 'tar' ];then
136
        wsrep_log_info "NOTE: Xtrabackup-based encryption - encrypt=1 - cannot be enabled with tar format"
136
        wsrep_log_info "NOTE: Xtrabackup-based encryption - encrypt=1 - cannot be enabled with tar format"
137
        encrypt=-1
137
        encrypt=-1
138
        return
138
        return
Lines 140-162 get_keys() Link Here
140
140
141
    wsrep_log_info "Xtrabackup based encryption enabled in my.cnf - Supported only from Xtrabackup 2.1.4"
141
    wsrep_log_info "Xtrabackup based encryption enabled in my.cnf - Supported only from Xtrabackup 2.1.4"
142
142
143
    if [[ -z $ealgo ]];then
143
    if [ -z "$ealgo" ];then
144
        wsrep_log_error "FATAL: Encryption algorithm empty from my.cnf, bailing out"
144
        wsrep_log_error "FATAL: Encryption algorithm empty from my.cnf, bailing out"
145
        exit 3
145
        exit 3
146
    fi
146
    fi
147
147
148
    if [[ -z $ekey && ! -r $ekeyfile ]];then
148
    if [ -z "$ekey" -a ! -r "$ekeyfile" ];then
149
        wsrep_log_error "FATAL: Either key or keyfile must be readable"
149
        wsrep_log_error "FATAL: Either key or keyfile must be readable"
150
        exit 3
150
        exit 3
151
    fi
151
    fi
152
152
153
    if [[ -z $ekey ]];then
153
    if [ -z "$ekey" ];then
154
        ecmd="${XBCRYPT_BIN} --encrypt-algo=$ealgo --encrypt-key-file=$ekeyfile"
154
        ecmd="${XBCRYPT_BIN} --encrypt-algo=$ealgo --encrypt-key-file=$ekeyfile"
155
    else
155
    else
156
        ecmd="${XBCRYPT_BIN} --encrypt-algo=$ealgo --encrypt-key=$ekey"
156
        ecmd="${XBCRYPT_BIN} --encrypt-algo=$ealgo --encrypt-key=$ekey"
157
    fi
157
    fi
158
158
159
    if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
159
    if [ "$WSREP_SST_OPT_ROLE" = "joiner" ];then
160
        ecmd+=" -d"
160
        ecmd+=" -d"
161
    fi
161
    fi
162
162
Lines 165-180 get_keys() Link Here
165
165
166
get_transfer()
166
get_transfer()
167
{
167
{
168
    if [[ -z $SST_PORT ]];then 
168
    if [ -z "$SST_PORT" ];then 
169
        TSST_PORT=4444
169
        TSST_PORT=4444
170
    else 
170
    else 
171
        TSST_PORT=$SST_PORT
171
        TSST_PORT=$SST_PORT
172
    fi
172
    fi
173
173
174
    if [[ $tfmt == 'nc' ]];then
174
    if [ "$tfmt" = 'nc' ];then
175
        wsrep_check_programs nc
175
        wsrep_check_programs nc
176
        wsrep_log_info "Using netcat as streamer"
176
        wsrep_log_info "Using netcat as streamer"
177
        if [[ "$WSREP_SST_OPT_ROLE"  == "joiner" ]];then
177
        if [ "$WSREP_SST_OPT_ROLE"  = "joiner" ];then
178
            if nc -h 2>&1 | grep -q ncat;then 
178
            if nc -h 2>&1 | grep -q ncat;then 
179
                # Ncat
179
                # Ncat
180
                tcmd="nc -l ${TSST_PORT}"
180
                tcmd="nc -l ${TSST_PORT}"
Lines 202-235 get_transfer() Link Here
202
        wsrep_check_programs socat
202
        wsrep_check_programs socat
203
        wsrep_log_info "Using socat as streamer"
203
        wsrep_log_info "Using socat as streamer"
204
204
205
        if [[ $encrypt -eq 2 || $encrypt -eq 3 ]] && ! socat -V | grep -q "WITH_OPENSSL 1";then
205
        if [ $encrypt -eq 2 -o $encrypt -eq 3 ] && ! socat -V | grep -q "WITH_OPENSSL 1";then
206
            wsrep_log_error "Encryption requested, but socat is not OpenSSL enabled (encrypt=$encrypt)"
206
            wsrep_log_error "Encryption requested, but socat is not OpenSSL enabled (encrypt=$encrypt)"
207
            exit 2
207
            exit 2
208
        fi
208
        fi
209
209
210
        if [[ $encrypt -eq 2 ]];then 
210
        if [ $encrypt -eq 2 ];then 
211
            wsrep_log_info "Using openssl based encryption with socat: with crt and pem"
211
            wsrep_log_info "Using openssl based encryption with socat: with crt and pem"
212
            if [[ -z $tpem || -z $tcert ]];then 
212
            if [ -z "$tpem" -o -z "$tcert" ];then 
213
                wsrep_log_error "Both PEM and CRT files required"
213
                wsrep_log_error "Both PEM and CRT files required"
214
                exit 22
214
                exit 22
215
            fi
215
            fi
216
            stagemsg+="-OpenSSL-Encrypted-2"
216
            stagemsg+="-OpenSSL-Encrypted-2"
217
            if [[ "$WSREP_SST_OPT_ROLE"  == "joiner" ]];then
217
            if [ "$WSREP_SST_OPT_ROLE" = "joiner" ];then
218
                wsrep_log_info "Decrypting with cert=${tpem}, cafile=${tcert}"
218
                wsrep_log_info "Decrypting with cert=${tpem}, cafile=${tcert}"
219
                tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tpem},cafile=${tcert}${sockopt} stdio"
219
                tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tpem},cafile=${tcert}${sockopt} stdio"
220
            else
220
            else
221
                wsrep_log_info "Encrypting with cert=${tpem}, cafile=${tcert}"
221
                wsrep_log_info "Encrypting with cert=${tpem}, cafile=${tcert}"
222
                tcmd="socat -u stdio openssl-connect:${REMOTEHOST}:${TSST_PORT},cert=${tpem},cafile=${tcert}${sockopt}"
222
                tcmd="socat -u stdio openssl-connect:${REMOTEHOST}:${TSST_PORT},cert=${tpem},cafile=${tcert}${sockopt}"
223
            fi
223
            fi
224
        elif [[ $encrypt -eq 3 ]];then
224
        elif [ $encrypt -eq 3 ];then
225
            wsrep_log_info "Using openssl based encryption with socat: with key and crt"
225
            wsrep_log_info "Using openssl based encryption with socat: with key and crt"
226
            if [[ -z $tpem || -z $tkey ]];then
226
            if [ -z $tpem || -z $tkey ];then
227
                wsrep_log_error "Both certificate and key files required"
227
                wsrep_log_error "Both certificate and key files required"
228
                exit 22
228
                exit 22
229
            fi
229
            fi
230
            stagemsg+="-OpenSSL-Encrypted-3"
230
            stagemsg+="-OpenSSL-Encrypted-3"
231
            if [[ "$WSREP_SST_OPT_ROLE"  == "joiner" ]];then
231
            if [ "$WSREP_SST_OPT_ROLE" = "joiner" ];then
232
                if [[ -z $tcert ]];then
232
                if [ -z "$tcert" ];then
233
                    wsrep_log_info "Decrypting with cert=${tpem}, key=${tkey}, verify=0"
233
                    wsrep_log_info "Decrypting with cert=${tpem}, key=${tkey}, verify=0"
234
                    tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tpem},key=${tkey},verify=0${sockopt} stdio"
234
                    tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tpem},key=${tkey},verify=0${sockopt} stdio"
235
                else
235
                else
Lines 237-243 get_transfer() Link Here
237
                    tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tpem},key=${tkey},cafile=${tcert}${sockopt} stdio"
237
                    tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tpem},key=${tkey},cafile=${tcert}${sockopt} stdio"
238
                fi
238
                fi
239
            else
239
            else
240
                if [[ -z $tcert ]];then
240
                if [ -z "$tcert" ];then
241
                    wsrep_log_info "Encrypting with cert=${tpem}, key=${tkey}, verify=0"
241
                    wsrep_log_info "Encrypting with cert=${tpem}, key=${tkey}, verify=0"
242
                    tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${tpem},key=${tkey},verify=0${sockopt}"
242
                    tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${tpem},key=${tkey},verify=0${sockopt}"
243
                else
243
                else
Lines 247-253 get_transfer() Link Here
247
            fi
247
            fi
248
248
249
        else 
249
        else 
250
            if [[ "$WSREP_SST_OPT_ROLE"  == "joiner" ]];then
250
            if [ "$WSREP_SST_OPT_ROLE" == "joiner" ];then
251
                tcmd="socat -u TCP-LISTEN:${TSST_PORT},reuseaddr${sockopt} stdio"
251
                tcmd="socat -u TCP-LISTEN:${TSST_PORT},reuseaddr${sockopt} stdio"
252
            else
252
            else
253
                tcmd="socat -u stdio TCP:${REMOTEIP}:${TSST_PORT}${sockopt}"
253
                tcmd="socat -u stdio TCP:${REMOTEIP}:${TSST_PORT}${sockopt}"
Lines 266-273 parse_cnf() Link Here
266
    # then grep for needed variable
266
    # then grep for needed variable
267
    # finally get the variable value (if variables has been specified multiple time use the last value only)
267
    # finally get the variable value (if variables has been specified multiple time use the last value only)
268
    reval=$($MY_PRINT_DEFAULTS $group | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2- | tail -1)
268
    reval=$($MY_PRINT_DEFAULTS $group | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2- | tail -1)
269
    if [[ -z $reval ]];then 
269
    if [ -z "$reval" ];then 
270
        [[ -n $3 ]] && reval=$3
270
        [ -n "$3" ] && reval=$3
271
    fi
271
    fi
272
    echo $reval
272
    echo $reval
273
}
273
}
Lines 298-315 adjust_progress() Link Here
298
        return
298
        return
299
    fi
299
    fi
300
300
301
    if [[ -n $progress && $progress != '1' ]];then 
301
    if [ -n "$progress" -a "$progress" != '1' ];then 
302
        if [[ -e $progress ]];then 
302
        if [ -e "$progress" ];then 
303
            pcmd+=" 2>>$progress"
303
            pcmd+=" 2>>$progress"
304
        else 
304
        else 
305
            pcmd+=" 2>$progress"
305
            pcmd+=" 2>$progress"
306
        fi
306
        fi
307
    elif [[ -z $progress && -n $rlimit  ]];then 
307
    elif [ -z "$progress" -a -n "$rlimit" ];then 
308
            # When rlimit is non-zero
308
            # When rlimit is non-zero
309
            pcmd="pv -q"
309
            pcmd="pv -q"
310
    fi 
310
    fi 
311
311
312
    if [[ -n $rlimit && "$WSREP_SST_OPT_ROLE"  == "donor" ]];then
312
    if [ -n "$rlimit" -a "$WSREP_SST_OPT_ROLE" = "donor" ];then
313
        wsrep_log_info "Rate-limiting SST to $rlimit"
313
        wsrep_log_info "Rate-limiting SST to $rlimit"
314
        pcmd+=" -L \$rlimit"
314
        pcmd+=" -L \$rlimit"
315
    fi
315
    fi
Lines 335-341 read_cnf() Link Here
335
    sdecomp=$(parse_cnf sst decompressor "")
335
    sdecomp=$(parse_cnf sst decompressor "")
336
336
337
    # Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html 
337
    # Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html 
338
    if [[ -z $ealgo ]];then
338
    if [ -z "$ealgo" ];then
339
        ealgo=$(parse_cnf sst encrypt-algo "")
339
        ealgo=$(parse_cnf sst encrypt-algo "")
340
        ekey=$(parse_cnf sst encrypt-key "")
340
        ekey=$(parse_cnf sst encrypt-key "")
341
        ekeyfile=$(parse_cnf sst encrypt-key-file "")
341
        ekeyfile=$(parse_cnf sst encrypt-key-file "")
Lines 352-369 read_cnf() Link Here
352
    ssystag=$(parse_cnf mysqld_safe syslog-tag "${SST_SYSLOG_TAG:-}")
352
    ssystag=$(parse_cnf mysqld_safe syslog-tag "${SST_SYSLOG_TAG:-}")
353
    ssystag+="-"
353
    ssystag+="-"
354
354
355
    if [[ $speciald -eq 0 ]];then 
355
    if [ $speciald -eq 0 ];then 
356
        wsrep_log_error "sst-special-dirs equal to 0 is not supported, falling back to 1"
356
        wsrep_log_error "sst-special-dirs equal to 0 is not supported, falling back to 1"
357
        speciald=1
357
        speciald=1
358
    fi 
358
    fi 
359
359
360
    if [[ $ssyslog -ne -1 ]];then 
360
    if [ $ssyslog -ne -1 ];then 
361
        if $MY_PRINT_DEFAULTS mysqld_safe | tr '_' '-' | grep -q -- "--syslog";then 
361
        if $MY_PRINT_DEFAULTS mysqld_safe | tr '_' '-' | grep -q -- "--syslog";then 
362
            ssyslog=1
362
            ssyslog=1
363
        fi
363
        fi
364
    fi
364
    fi
365
365
366
    if [[ $encrypt -eq 1 ]]; then
366
    if [ $encrypt -eq 1 ]; then
367
        wsrep_log_error "Xtrabackup-based encryption is currently not" \
367
        wsrep_log_error "Xtrabackup-based encryption is currently not" \
368
            "supported with MariaBackup"
368
            "supported with MariaBackup"
369
        exit 2
369
        exit 2
Lines 372-380 read_cnf() Link Here
372
372
373
get_stream()
373
get_stream()
374
{
374
{
375
    if [[ $sfmt == 'xbstream' ]];then 
375
    if [ "$sfmt" == 'xbstream' ];then 
376
        wsrep_log_info "Streaming with xbstream"
376
        wsrep_log_info "Streaming with xbstream"
377
        if [[ "$WSREP_SST_OPT_ROLE"  == "joiner" ]];then
377
        if [ "$WSREP_SST_OPT_ROLE" = "joiner" ];then
378
            strmcmd="${XBSTREAM_BIN} -x"
378
            strmcmd="${XBSTREAM_BIN} -x"
379
        else
379
        else
380
            strmcmd="${XBSTREAM_BIN} -c \${INFO_FILE}"
380
            strmcmd="${XBSTREAM_BIN} -c \${INFO_FILE}"
Lines 382-388 get_stream() Link Here
382
    else
382
    else
383
        sfmt="tar"
383
        sfmt="tar"
384
        wsrep_log_info "Streaming with tar"
384
        wsrep_log_info "Streaming with tar"
385
        if [[ "$WSREP_SST_OPT_ROLE"  == "joiner" ]];then
385
        if [ "$WSREP_SST_OPT_ROLE" = "joiner" ];then
386
            strmcmd="tar xfi - "
386
            strmcmd="tar xfi - "
387
        else
387
        else
388
            strmcmd="tar cf - \${INFO_FILE} "
388
            strmcmd="tar cf - \${INFO_FILE} "
Lines 395-401 get_proc() Link Here
395
{
395
{
396
    set +e
396
    set +e
397
    nproc=$(grep -c processor /proc/cpuinfo)
397
    nproc=$(grep -c processor /proc/cpuinfo)
398
    [[ -z $nproc || $nproc -eq 0 ]] && nproc=1
398
    [ -z "$nproc" -o $nproc -eq 0 ] && nproc=1
399
    set -e
399
    set -e
400
}
400
}
401
401
Lines 409-426 cleanup_joiner() Link Here
409
{
409
{
410
    # Since this is invoked just after exit NNN
410
    # Since this is invoked just after exit NNN
411
    local estatus=$?
411
    local estatus=$?
412
    if [[ $estatus -ne 0 ]];then 
412
    if [ $estatus -ne 0 ];then 
413
        wsrep_log_error "Cleanup after exit with status:$estatus"
413
        wsrep_log_error "Cleanup after exit with status:$estatus"
414
    elif [ "${WSREP_SST_OPT_ROLE}" = "joiner" ];then
414
    elif [ "${WSREP_SST_OPT_ROLE}" = "joiner" ];then
415
        wsrep_log_info "Removing the sst_in_progress file"
415
        wsrep_log_info "Removing the sst_in_progress file"
416
        wsrep_cleanup_progress_file
416
        wsrep_cleanup_progress_file
417
    fi
417
    fi
418
    if [[ -n $progress && -p $progress ]];then 
418
    if [ -n "$progress" && -p "$progress" ];then 
419
        wsrep_log_info "Cleaning up fifo file $progress"
419
        wsrep_log_info "Cleaning up fifo file $progress"
420
        rm $progress
420
        rm $progress
421
    fi
421
    fi
422
    if [[ -n ${STATDIR:-} ]];then 
422
    if [ -n "${STATDIR:-}" ];then 
423
       [[ -d $STATDIR ]] && rm -rf $STATDIR
423
       [ -d "$STATDIR" ] && rm -rf $STATDIR
424
    fi
424
    fi
425
425
426
    # Final cleanup 
426
    # Final cleanup 
Lines 428-438 cleanup_joiner() Link Here
428
428
429
    # This means no setsid done in mysqld.
429
    # This means no setsid done in mysqld.
430
    # We don't want to kill mysqld here otherwise.
430
    # We don't want to kill mysqld here otherwise.
431
    if [[ $$ -eq $pgid ]];then
431
    if [ $$ -eq $pgid ];then
432
432
433
        # This means a signal was delivered to the process.
433
        # This means a signal was delivered to the process.
434
        # So, more cleanup. 
434
        # So, more cleanup. 
435
        if [[ $estatus -ge 128 ]];then 
435
        if [ $estatus -ge 128 ];then 
436
            kill -KILL -$$ || true
436
            kill -KILL -$$ || true
437
        fi
437
        fi
438
438
Lines 451-461 cleanup_donor() Link Here
451
{
451
{
452
    # Since this is invoked just after exit NNN
452
    # Since this is invoked just after exit NNN
453
    local estatus=$?
453
    local estatus=$?
454
    if [[ $estatus -ne 0 ]];then 
454
    if [ $estatus -ne 0 ];then 
455
        wsrep_log_error "Cleanup after exit with status:$estatus"
455
        wsrep_log_error "Cleanup after exit with status:$estatus"
456
    fi
456
    fi
457
457
458
    if [[ -n ${XTRABACKUP_PID:-} ]];then 
458
    if [ -n "${XTRABACKUP_PID:-}" ];then 
459
        if check_pid $XTRABACKUP_PID
459
        if check_pid $XTRABACKUP_PID
460
        then
460
        then
461
            wsrep_log_error "xtrabackup process is still running. Killing... "
461
            wsrep_log_error "xtrabackup process is still running. Killing... "
Lines 465-483 cleanup_donor() Link Here
465
    fi
465
    fi
466
    rm -f ${DATA}/${IST_FILE} || true
466
    rm -f ${DATA}/${IST_FILE} || true
467
467
468
    if [[ -n $progress && -p $progress ]];then 
468
    if [ -n "$progress" -a -p "$progress" ];then 
469
        wsrep_log_info "Cleaning up fifo file $progress"
469
        wsrep_log_info "Cleaning up fifo file $progress"
470
        rm -f $progress || true
470
        rm -f $progress || true
471
    fi
471
    fi
472
472
473
    wsrep_log_info "Cleaning up temporary directories"
473
    wsrep_log_info "Cleaning up temporary directories"
474
474
475
    if [[ -n $xtmpdir ]];then 
475
    if [ -n "$xtmpdir" ];then 
476
       [[ -d $xtmpdir ]] &&  rm -rf $xtmpdir || true
476
       [ -d "$xtmpdir" ] &&  rm -rf $xtmpdir || true
477
    fi
477
    fi
478
478
479
    if [[ -n $itmpdir ]];then 
479
    if [ -n "$itmpdir" ];then 
480
       [[ -d $itmpdir ]] &&  rm -rf $itmpdir || true
480
       [ -d "$itmpdir" ] &&  rm -rf $itmpdir || true
481
    fi
481
    fi
482
482
483
    # Final cleanup 
483
    # Final cleanup 
Lines 485-495 cleanup_donor() Link Here
485
485
486
    # This means no setsid done in mysqld.
486
    # This means no setsid done in mysqld.
487
    # We don't want to kill mysqld here otherwise.
487
    # We don't want to kill mysqld here otherwise.
488
    if [[ $$ -eq $pgid ]];then
488
    if [ $$ -eq $pgid ];then
489
489
490
        # This means a signal was delivered to the process.
490
        # This means a signal was delivered to the process.
491
        # So, more cleanup. 
491
        # So, more cleanup. 
492
        if [[ $estatus -ge 128 ]];then 
492
        if [ $estatus -ge 128 ];then 
493
            kill -KILL -$$ || true
493
            kill -KILL -$$ || true
494
        fi
494
        fi
495
495
Lines 509-519 kill_xtrabackup() Link Here
509
509
510
setup_ports()
510
setup_ports()
511
{
511
{
512
    if [[ "$WSREP_SST_OPT_ROLE"  == "donor" ]];then
512
    if [ "$WSREP_SST_OPT_ROLE" = "donor" ];then
513
        SST_PORT=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $2 }')
513
        SST_PORT=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $2 }')
514
        REMOTEIP=$(echo $WSREP_SST_OPT_ADDR | awk -F ':' '{ print $1 }')
514
        REMOTEIP=$(echo $WSREP_SST_OPT_ADDR | awk -F ':' '{ print $1 }')
515
        REMOTEHOST=$(getent hosts $REMOTEIP | awk '{ print $2 }')
515
        REMOTEHOST=$(getent hosts $REMOTEIP | awk '{ print $2 }')
516
        if [[ -z $REMOTEHOST ]];then
516
        if [ -z "$REMOTEHOST" ];then
517
            REMOTEHOST=$REMOTEIP
517
            REMOTEHOST=$REMOTEIP
518
        fi
518
        fi
519
        lsn=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $4 }')
519
        lsn=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $4 }')
Lines 532-538 wait_for_listen() Link Here
532
    local MODULE=$3
532
    local MODULE=$3
533
    for i in {1..50}
533
    for i in {1..50}
534
    do
534
    do
535
        ss -p state listening "( sport = :$PORT )" | grep -qE 'socat|nc' && break
535
        if [ "$OS" = "FreeBSD" ];then
536
            sockstat -46lp $PORT | grep -qE "^[^ ]* *(socat|nc) *[^ ]* *[^ ]* *[^ ]* *[^ ]*:$PORT" && break
537
        else
538
            ss -p state listening "( sport = :$PORT )" | grep -qE 'socat|nc' && break
539
        fi
536
        sleep 0.2
540
        sleep 0.2
537
    done
541
    done
538
    echo "ready ${ADDR}/${MODULE}//$sst_ver"
542
    echo "ready ${ADDR}/${MODULE}//$sst_ver"
Lines 541-550 wait_for_listen() Link Here
541
check_extra()
545
check_extra()
542
{
546
{
543
    local use_socket=1
547
    local use_socket=1
544
    if [[ $uextra -eq 1 ]];then 
548
    if [ $uextra -eq 1 ];then 
545
        if $MY_PRINT_DEFAULTS --mysqld | tr '_' '-' | grep -- "--thread-handling=" | grep -q 'pool-of-threads';then 
549
        if $MY_PRINT_DEFAULTS --mysqld | tr '_' '-' | grep -- "--thread-handling=" | grep -q 'pool-of-threads';then 
546
            local eport=$($MY_PRINT_DEFAULTS --mysqld | tr '_' '-' | grep -- "--extra-port=" | cut -d= -f2)
550
            local eport=$($MY_PRINT_DEFAULTS --mysqld | tr '_' '-' | grep -- "--extra-port=" | cut -d= -f2)
547
            if [[ -n $eport ]];then 
551
            if [ -n "$eport" ];then 
548
                # Xtrabackup works only locally.
552
                # Xtrabackup works only locally.
549
                # Hence, setting host to 127.0.0.1 unconditionally. 
553
                # Hence, setting host to 127.0.0.1 unconditionally. 
550
                wsrep_log_info "SST through extra_port $eport"
554
                wsrep_log_info "SST through extra_port $eport"
Lines 558-564 check_extra() Link Here
558
            wsrep_log_info "Thread pool not set, ignore the option use_extra"
562
            wsrep_log_info "Thread pool not set, ignore the option use_extra"
559
        fi
563
        fi
560
    fi
564
    fi
561
    if [[ $use_socket -eq 1 ]] && [[ -n "${WSREP_SST_OPT_SOCKET}" ]];then
565
    if [ $use_socket -eq 1 ] && [ -n "${WSREP_SST_OPT_SOCKET}" ];then
562
        INNOEXTRA+=" --socket=${WSREP_SST_OPT_SOCKET}"
566
        INNOEXTRA+=" --socket=${WSREP_SST_OPT_SOCKET}"
563
    fi
567
    fi
564
}
568
}
Lines 571-577 recv_joiner() Link Here
571
    local checkf=$4
575
    local checkf=$4
572
    local ltcmd
576
    local ltcmd
573
577
574
    if [[ ! -d ${dir} ]];then
578
    if [ ! -d "${dir}" ];then
575
        # This indicates that IST is in progress
579
        # This indicates that IST is in progress
576
        return
580
        return
577
    fi
581
    fi
Lines 579-585 recv_joiner() Link Here
579
    pushd ${dir} 1>/dev/null
583
    pushd ${dir} 1>/dev/null
580
    set +e
584
    set +e
581
585
582
    if [[ $tmt -gt 0 ]] && command -v timeout >/dev/null;then
586
    if [ $tmt -gt 0 ] && command -v timeout >/dev/null;then
583
        if timeout --help | grep -q -- '-k';then 
587
        if timeout --help | grep -q -- '-k';then 
584
            ltcmd="timeout -k $(( tmt+10 )) $tmt $tcmd"
588
            ltcmd="timeout -k $(( tmt+10 )) $tmt $tcmd"
585
        else 
589
        else 
Lines 587-612 recv_joiner() Link Here
587
        fi
591
        fi
588
        timeit "$msg" "$ltcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
592
        timeit "$msg" "$ltcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
589
    else 
593
    else 
590
        timeit "$msg" "$tcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
594
        if [ -n "$shisbash" ];then
595
            timeit "$msg" "$tcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
596
        else
597
            timeit "$msg" "$tcmd | $strmcmd; RC=( "\$?" )"
598
        fi
591
    fi
599
    fi
592
600
593
    set -e
601
    set -e
594
    popd 1>/dev/null 
602
    popd 1>/dev/null 
595
603
596
    if [[ ${RC[0]} -eq 124 ]];then 
604
    if [ -n "$shisbash" ];then
597
        wsrep_log_error "Possible timeout in receving first data from donor in gtid stage"
605
        if [ ${RC[0]} -eq 124 ];then 
598
        exit 32
606
            wsrep_log_error "Possible timeout in receving first data from donor in gtid stage"
599
    fi
607
            exit 32
608
        fi
600
609
601
    for ecode in "${RC[@]}";do 
610
        for ecode in "${RC[@]}";do 
602
        if [[ $ecode -ne 0 ]];then 
611
            if [ $ecode -ne 0 ];then 
612
                wsrep_log_error "Error while getting data from donor node: " \
613
                                "exit codes: ${RC[@]}"
614
                exit 32
615
            fi
616
        done
617
    else
618
        if [ $RC -ne 0 ];then
603
            wsrep_log_error "Error while getting data from donor node: " \
619
            wsrep_log_error "Error while getting data from donor node: " \
604
                            "exit codes: ${RC[@]}"
620
                            "exit code: $RC"
605
            exit 32
621
            exit 32
606
        fi
622
        fi
607
    done
623
    fi
608
624
609
    if [[ $checkf -eq 1 && ! -r "${MAGIC_FILE}" ]];then
625
    if [ $checkf -eq 1 -a ! -r "${MAGIC_FILE}" ];then
610
        # this message should cause joiner to abort
626
        # this message should cause joiner to abort
611
        wsrep_log_error "xtrabackup process ended without creating '${MAGIC_FILE}'"
627
        wsrep_log_error "xtrabackup process ended without creating '${MAGIC_FILE}'"
612
        wsrep_log_info "Contents of datadir" 
628
        wsrep_log_info "Contents of datadir" 
Lines 623-648 send_donor() Link Here
623
639
624
    pushd ${dir} 1>/dev/null
640
    pushd ${dir} 1>/dev/null
625
    set +e
641
    set +e
626
    timeit "$msg" "$strmcmd | $tcmd; RC=( "\${PIPESTATUS[@]}" )"
642
    if [ -n "$shisbash" ];then
643
        timeit "$msg" "$strmcmd | $tcmd; RC=( "\${PIPESTATUS[@]}" )"
644
    else
645
        timeit "$msg" "$strmcmd | $tcmd; RC=( "\$RC" )"
646
    fi
627
    set -e
647
    set -e
628
    popd 1>/dev/null 
648
    popd 1>/dev/null 
629
649
630
650
    if [ -n "$shisbash" ];then
631
    for ecode in "${RC[@]}";do 
651
        for ecode in "${RC[@]}";do 
632
        if [[ $ecode -ne 0 ]];then 
652
            if [ $ecode -ne 0 ];then 
653
                wsrep_log_error "Error while getting data from donor node: " \
654
                                "exit codes: ${RC[@]}"
655
                exit 32
656
            fi
657
        done
658
    else
659
            if [ $RC -ne 0 ];then
633
            wsrep_log_error "Error while getting data from donor node: " \
660
            wsrep_log_error "Error while getting data from donor node: " \
634
                            "exit codes: ${RC[@]}"
661
                            "exit codes: $RC"
635
            exit 32
662
            exit 32
636
        fi
663
        fi
637
    done
664
    fi
638
639
}
665
}
640
666
641
wsrep_check_programs "$INNOBACKUPEX_BIN"
667
wsrep_check_programs "$INNOBACKUPEX_BIN"
642
668
643
rm -f "${MAGIC_FILE}"
669
rm -f "${MAGIC_FILE}"
644
670
645
if [[ ! ${WSREP_SST_OPT_ROLE} == 'joiner' && ! ${WSREP_SST_OPT_ROLE} == 'donor' ]];then 
671
if [ ! ${WSREP_SST_OPT_ROLE} = 'joiner' -a ! ${WSREP_SST_OPT_ROLE} = 'donor' ];then 
646
    wsrep_log_error "Invalid role ${WSREP_SST_OPT_ROLE}"
672
    wsrep_log_error "Invalid role ${WSREP_SST_OPT_ROLE}"
647
    exit 22
673
    exit 22
648
fi
674
fi
Lines 654-660 if ${INNOBACKUPEX_BIN} /tmp --help 2>/de Link Here
654
    disver="--no-version-check"
680
    disver="--no-version-check"
655
fi
681
fi
656
682
657
if [[ ${FORCE_FTWRL:-0} -eq 1 ]];then 
683
if [ ${FORCE_FTWRL:-0} -eq 1 ];then 
658
    wsrep_log_info "Forcing FTWRL due to environment variable FORCE_FTWRL equal to $FORCE_FTWRL"
684
    wsrep_log_info "Forcing FTWRL due to environment variable FORCE_FTWRL equal to $FORCE_FTWRL"
659
    iopts+=" --no-backup-locks "
685
    iopts+=" --no-backup-locks "
660
fi
686
fi
Lines 662-668 fi Link Here
662
688
663
INNOEXTRA=""
689
INNOEXTRA=""
664
690
665
if [[ $ssyslog -eq 1 ]];then 
691
if [ $ssyslog -eq 1 ];then 
666
692
667
    if ! command -v logger >/dev/null;then
693
    if ! command -v logger >/dev/null;then
668
        wsrep_log_error "logger not in path: $PATH. Ignoring"
694
        wsrep_log_error "logger not in path: $PATH. Ignoring"
Lines 703-715 then Link Here
703
    if [ $WSREP_SST_OPT_BYPASS -eq 0 ]
729
    if [ $WSREP_SST_OPT_BYPASS -eq 0 ]
704
    then
730
    then
705
        usrst=0
731
        usrst=0
706
        if [[ -z $sst_ver ]];then 
732
        if [ -z "$sst_ver" ];then 
707
            wsrep_log_error "Upgrade joiner to 5.6.21 or higher for backup locks support"
733
            wsrep_log_error "Upgrade joiner to 5.6.21 or higher for backup locks support"
708
            wsrep_log_error "The joiner is not supported for this version of donor"
734
            wsrep_log_error "The joiner is not supported for this version of donor"
709
            exit 93
735
            exit 93
710
        fi
736
        fi
711
737
712
        if [[ -z $(parse_cnf mysqld tmpdir "") && -z $(parse_cnf xtrabackup tmpdir "") ]];then 
738
        if [ -z $(parse_cnf mysqld tmpdir "") -a -z $(parse_cnf xtrabackup tmpdir "") ];then 
713
            xtmpdir=$(mktemp -d)
739
            xtmpdir=$(mktemp -d)
714
            tmpopts=" --tmpdir=$xtmpdir "
740
            tmpopts=" --tmpdir=$xtmpdir "
715
            wsrep_log_info "Using $xtmpdir as xtrabackup temporary directory"
741
            wsrep_log_info "Using $xtmpdir as xtrabackup temporary directory"
Lines 718-738 then Link Here
718
        itmpdir=$(mktemp -d)
744
        itmpdir=$(mktemp -d)
719
        wsrep_log_info "Using $itmpdir as innobackupex temporary directory"
745
        wsrep_log_info "Using $itmpdir as innobackupex temporary directory"
720
746
721
        if [[ -n "${WSREP_SST_OPT_USER:-}" && "$WSREP_SST_OPT_USER" != "(null)" ]]; then
747
        if [ -n "${WSREP_SST_OPT_USER:-}" -a "$WSREP_SST_OPT_USER" != "(null)" ]; then
722
           INNOEXTRA+=" --user=$WSREP_SST_OPT_USER"
748
           INNOEXTRA+=" --user=$WSREP_SST_OPT_USER"
723
           usrst=1
749
           usrst=1
724
        fi
750
        fi
725
751
726
        if [ -n "${WSREP_SST_OPT_PSWD:-}" ]; then
752
        if [ -n "${WSREP_SST_OPT_PSWD:-}" ];then
727
           INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD"
753
           INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD"
728
        elif [[ $usrst -eq 1 ]];then
754
        elif [ $usrst -eq 1 ];then
729
           # Empty password, used for testing, debugging etc.
755
           # Empty password, used for testing, debugging etc.
730
           INNOEXTRA+=" --password="
756
           INNOEXTRA+=" --password="
731
        fi
757
        fi
732
758
733
        get_keys
759
        get_keys
734
        if [[ $encrypt -eq 1 ]];then
760
        if [ $encrypt -eq 1 ];then
735
            if [[ -n $ekey ]];then
761
            if [ -n "$ekey" ];then
736
                INNOEXTRA+=" --encrypt=$ealgo --encrypt-key=$ekey "
762
                INNOEXTRA+=" --encrypt=$ealgo --encrypt-key=$ekey "
737
            else 
763
            else 
738
                INNOEXTRA+=" --encrypt=$ealgo --encrypt-key-file=$ekeyfile "
764
                INNOEXTRA+=" --encrypt=$ealgo --encrypt-key-file=$ekeyfile "
Lines 750-762 then Link Here
750
776
751
        ttcmd="$tcmd"
777
        ttcmd="$tcmd"
752
778
753
        if [[ $encrypt -eq 1 ]];then
779
        if [ $encrypt -eq 1 ];then
754
            if [[ -n $scomp ]];then 
780
            if [ -n "$scomp" ];then 
755
                tcmd=" $ecmd | $scomp | $tcmd "
781
                tcmd=" $ecmd | $scomp | $tcmd "
756
            else 
782
            else 
757
                tcmd=" $ecmd | $tcmd "
783
                tcmd=" $ecmd | $tcmd "
758
            fi
784
            fi
759
        elif [[ -n $scomp ]];then 
785
        elif [ -n "$scomp" ];then 
760
            tcmd=" $scomp | $tcmd "
786
            tcmd=" $scomp | $tcmd "
761
        fi
787
        fi
762
788
Lines 764-773 then Link Here
764
        send_donor $DATA "${stagemsg}-gtid"
790
        send_donor $DATA "${stagemsg}-gtid"
765
791
766
        tcmd="$ttcmd"
792
        tcmd="$ttcmd"
767
        if [[ -n $progress ]];then 
793
        if [ -n "$progress" ];then 
768
            get_footprint
794
            get_footprint
769
            tcmd="$pcmd | $tcmd"
795
            tcmd="$pcmd | $tcmd"
770
        elif [[ -n $rlimit ]];then 
796
        elif [ -n "$rlimit" ];then 
771
            adjust_progress
797
            adjust_progress
772
            tcmd="$pcmd | $tcmd"
798
            tcmd="$pcmd | $tcmd"
773
        fi
799
        fi
Lines 777-797 then Link Here
777
803
778
        wsrep_log_info "Streaming the backup to joiner at ${REMOTEIP} ${SST_PORT:-4444}"
804
        wsrep_log_info "Streaming the backup to joiner at ${REMOTEIP} ${SST_PORT:-4444}"
779
805
780
        if [[ -n $scomp ]];then 
806
        if [ -n "$scomp" ];then 
781
            tcmd="$scomp | $tcmd"
807
            tcmd="$scomp | $tcmd"
782
        fi
808
        fi
783
809
784
        set +e
810
        set +e
785
        timeit "${stagemsg}-SST" "$INNOBACKUP | $tcmd; RC=( "\${PIPESTATUS[@]}" )"
811
        if [ -n "$shisbash" ];then
812
            timeit "${stagemsg}-SST" "$INNOBACKUP | $tcmd; RC=( "\${PIPESTATUS[@]}" )"
813
        else
814
            timeit "${stagemsg}-SST" "$INNOBACKUP | $tcmd; RC=( "\$RC" )"
815
        fi
786
        set -e
816
        set -e
787
817
788
        if [ ${RC[0]} -ne 0 ]; then
818
        if [ -n "$shisbash" ];then
789
          wsrep_log_error "${INNOBACKUPEX_BIN} finished with error: ${RC[0]}. " \
819
            if [ ${RC[0]} -ne 0 ]; then
790
                          "Check ${DATA}/innobackup.backup.log"
820
              wsrep_log_error "${INNOBACKUPEX_BIN} finished with error: ${RC[0]}. " \
791
          exit 22
821
                              "Check ${DATA}/innobackup.backup.log"
792
        elif [[ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ]];then 
822
              exit 22
793
          wsrep_log_error "$tcmd finished with error: ${RC[1]}"
823
            elif [ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ];then 
794
          exit 22
824
              wsrep_log_error "$tcmd finished with error: ${RC[1]}"
825
              exit 22
826
            fi
827
        else
828
        if [ $RC -ne 0 ];then
829
            wsrep_log_error "${INNOBACKUPEX_BIN} finished with error: $RC. " \
830
                            "Check ${DATA}/innobackup.backup.log"
831
            exit 22
795
        fi
832
        fi
796
833
797
        # innobackupex implicitly writes PID to fixed location in $xtmpdir
834
        # innobackupex implicitly writes PID to fixed location in $xtmpdir
Lines 808-820 then Link Here
808
        echo "${WSREP_SST_OPT_GTID} ${WSREP_SST_OPT_GTID_DOMAIN_ID}" > "${MAGIC_FILE}"
845
        echo "${WSREP_SST_OPT_GTID} ${WSREP_SST_OPT_GTID_DOMAIN_ID}" > "${MAGIC_FILE}"
809
        echo "1" > "${DATA}/${IST_FILE}"
846
        echo "1" > "${DATA}/${IST_FILE}"
810
        get_keys
847
        get_keys
811
        if [[ $encrypt -eq 1 ]];then
848
        if [ $encrypt -eq 1 ];then
812
            if [[ -n $scomp ]];then 
849
            if [ -n "$scomp" ];then 
813
                tcmd=" $ecmd | $scomp | $tcmd "
850
                tcmd=" $ecmd | $scomp | $tcmd "
814
            else
851
            else
815
                tcmd=" $ecmd | $tcmd "
852
                tcmd=" $ecmd | $tcmd "
816
            fi
853
            fi
817
        elif [[ -n $scomp ]];then 
854
        elif [ -n "$scomp" ];then 
818
            tcmd=" $scomp | $tcmd "
855
            tcmd=" $scomp | $tcmd "
819
        fi
856
        fi
820
        strmcmd+=" \${IST_FILE}"
857
        strmcmd+=" \${IST_FILE}"
Lines 828-835 then Link Here
828
865
829
elif [ "${WSREP_SST_OPT_ROLE}" = "joiner" ]
866
elif [ "${WSREP_SST_OPT_ROLE}" = "joiner" ]
830
then
867
then
831
    [[ -e $SST_PROGRESS_FILE ]] && wsrep_log_info "Stale sst_in_progress file: $SST_PROGRESS_FILE"
868
    [ -e "$SST_PROGRESS_FILE" ] && wsrep_log_info "Stale sst_in_progress file: $SST_PROGRESS_FILE"
832
    [[ -n $SST_PROGRESS_FILE ]] && touch $SST_PROGRESS_FILE
869
    [ -n "$SST_PROGRESS_FILE" ] && touch $SST_PROGRESS_FILE
833
870
834
    ib_home_dir=$(parse_cnf mysqld innodb-data-home-dir "")
871
    ib_home_dir=$(parse_cnf mysqld innodb-data-home-dir "")
835
    ib_log_dir=$(parse_cnf mysqld innodb-log-group-home-dir "")
872
    ib_log_dir=$(parse_cnf mysqld innodb-log-group-home-dir "")
Lines 860-878 then Link Here
860
    trap sig_joiner_cleanup HUP PIPE INT TERM
897
    trap sig_joiner_cleanup HUP PIPE INT TERM
861
    trap cleanup_joiner EXIT
898
    trap cleanup_joiner EXIT
862
899
863
    if [[ -n $progress ]];then 
900
    if [ -n "$progress" ];then 
864
        adjust_progress
901
        adjust_progress
865
        tcmd+=" | $pcmd"
902
        tcmd+=" | $pcmd"
866
    fi
903
    fi
867
904
868
    get_keys
905
    get_keys
869
    if [[ $encrypt -eq 1 && $sencrypted -eq 1 ]];then
906
    if [ $encrypt -eq 1 -a $sencrypted -eq 1 ];then
870
        if [[ -n $sdecomp ]];then 
907
        if [ -n "$sdecomp" ];then 
871
            strmcmd=" $sdecomp | $ecmd | $strmcmd"
908
            strmcmd=" $sdecomp | $ecmd | $strmcmd"
872
        else 
909
        else 
873
            strmcmd=" $ecmd | $strmcmd"
910
            strmcmd=" $ecmd | $strmcmd"
874
        fi
911
        fi
875
    elif [[ -n $sdecomp ]];then 
912
    elif [ -n "$sdecomp" ];then 
876
            strmcmd=" $sdecomp | $strmcmd"
913
            strmcmd=" $sdecomp | $strmcmd"
877
    fi
914
    fi
878
915
Lines 890-896 then Link Here
890
    if [ ! -r "${STATDIR}/${IST_FILE}" ]
927
    if [ ! -r "${STATDIR}/${IST_FILE}" ]
891
    then
928
    then
892
929
893
        if [[ -d ${DATA}/.sst ]];then
930
        if [ -d "${DATA}/.sst" ];then
894
            wsrep_log_info "WARNING: Stale temporary SST directory: ${DATA}/.sst from previous state transfer. Removing"
931
            wsrep_log_info "WARNING: Stale temporary SST directory: ${DATA}/.sst from previous state transfer. Removing"
895
            rm -rf ${DATA}/.sst
932
            rm -rf ${DATA}/.sst
896
        fi
933
        fi
Lines 901-913 then Link Here
901
938
902
939
903
        wsrep_log_info "Cleaning the existing datadir and innodb-data/log directories"
940
        wsrep_log_info "Cleaning the existing datadir and innodb-data/log directories"
904
        find $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1  -regex $cpat  -prune  -o -exec rm -rfv {} 1>&2 \+
941
        if [ "$OS" = "FreeBSD" ]; then
942
            find -E $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1  -regex $cpat  -prune  -o -exec rm -rfv {} 1>&2 \+
943
        else
944
            find $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1  -regex $cpat  -prune  -o -exec rm -rfv {} 1>&2 \+
945
        fi
905
946
906
        tempdir=$(parse_cnf mysqld log-bin "")
947
        tempdir=$(parse_cnf mysqld log-bin "")
907
        if [[ -n ${tempdir:-} ]];then
948
        if [ -n "${tempdir:-}" ];then
908
            binlog_dir=$(dirname $tempdir)
949
            binlog_dir=$(dirname $tempdir)
909
            binlog_file=$(basename $tempdir)
950
            binlog_file=$(basename $tempdir)
910
            if [[ -n ${binlog_dir:-} && $binlog_dir != '.' && $binlog_dir != $DATA ]];then
951
            if [ -n "${binlog_dir:-}" -a "$binlog_dir" != '.' -a "$binlog_dir" != "$DATA" ];then
911
                pattern="$binlog_dir/$binlog_file\.[0-9]+$"
952
                pattern="$binlog_dir/$binlog_file\.[0-9]+$"
912
                wsrep_log_info "Cleaning the binlog directory $binlog_dir as well"
953
                wsrep_log_info "Cleaning the binlog directory $binlog_dir as well"
913
                find $binlog_dir -maxdepth 1 -type f -regex $pattern -exec rm -fv {} 1>&2 \+ || true
954
                find $binlog_dir -maxdepth 1 -type f -regex $pattern -exec rm -fv {} 1>&2 \+ || true
Lines 915-950 then Link Here
915
            fi
956
            fi
916
        fi
957
        fi
917
958
918
919
920
        TDATA=${DATA}
959
        TDATA=${DATA}
921
        DATA="${DATA}/.sst"
960
        DATA="${DATA}/.sst"
922
961
923
924
        MAGIC_FILE="${DATA}/${INFO_FILE}"
962
        MAGIC_FILE="${DATA}/${INFO_FILE}"
925
        wsrep_log_info "Waiting for SST streaming to complete!"
963
        wsrep_log_info "Waiting for SST streaming to complete!"
926
        wait $jpid
964
        wait $jpid
927
965
928
        get_proc
966
        get_proc
929
967
930
        if [[ ! -s ${DATA}/xtrabackup_checkpoints ]];then 
968
        if [ ! -s "${DATA}/xtrabackup_checkpoints" ];then 
931
            wsrep_log_error "xtrabackup_checkpoints missing, failed innobackupex/SST on donor"
969
            wsrep_log_error "xtrabackup_checkpoints missing, failed innobackupex/SST on donor"
932
            exit 2
970
            exit 2
933
        fi
971
        fi
934
972
935
        # Rebuild indexes for compact backups
973
        # Rebuild indexes for compact backups
936
        if grep -q 'compact = 1' ${DATA}/xtrabackup_checkpoints;then 
974
        if grep -q 'compact = 1' "${DATA}/xtrabackup_checkpoints";then 
937
            wsrep_log_info "Index compaction detected"
975
            wsrep_log_info "Index compaction detected"
938
            rebuild=1
976
            rebuild=1
939
        fi
977
        fi
940
978
941
        if [[ $rebuild -eq 1 ]];then 
979
        if [ $rebuild -eq 1 ];then 
942
            nthreads=$(parse_cnf xtrabackup rebuild-threads $nproc)
980
            nthreads=$(parse_cnf xtrabackup rebuild-threads $nproc)
943
            wsrep_log_info "Rebuilding during prepare with $nthreads threads"
981
            wsrep_log_info "Rebuilding during prepare with $nthreads threads"
944
            rebuildcmd="--rebuild-indexes --rebuild-threads=$nthreads"
982
            rebuildcmd="--rebuild-indexes --rebuild-threads=$nthreads"
945
        fi
983
        fi
946
984
947
        if test -n "$(find ${DATA} -maxdepth 1 -type f -name '*.qp' -print -quit)";then
985
        if [ -n "$(find ${DATA} -maxdepth 1 -type f -name '*.qp' -print -quit)" ];then
948
986
949
            wsrep_log_info "Compressed qpress files found"
987
            wsrep_log_info "Compressed qpress files found"
950
988
Lines 953-959 then Link Here
953
                exit 22
991
                exit 22
954
            fi
992
            fi
955
993
956
            if [[ -n $progress ]] && pv --help | grep -q 'line-mode';then
994
            if [ -n "$progress" ] && pv --help | grep -q 'line-mode';then
957
                count=$(find ${DATA} -type f -name '*.qp' | wc -l)
995
                count=$(find ${DATA} -type f -name '*.qp' | wc -l)
958
                count=$(( count*2 ))
996
                count=$(( count*2 ))
959
                if pv --help | grep -q FORMAT;then 
997
                if pv --help | grep -q FORMAT;then 
Lines 974-983 then Link Here
974
            timeit "Joiner-Decompression" "find ${DATA} -type f -name '*.qp' -printf '%p\n%h\n' | $dcmd"
1012
            timeit "Joiner-Decompression" "find ${DATA} -type f -name '*.qp' -printf '%p\n%h\n' | $dcmd"
975
            extcode=$?
1013
            extcode=$?
976
1014
977
            if [[ $extcode -eq 0 ]];then
1015
            if [ $extcode -eq 0 ];then
978
                wsrep_log_info "Removing qpress files after decompression"
1016
                wsrep_log_info "Removing qpress files after decompression"
979
                find ${DATA} -type f -name '*.qp' -delete 
1017
                find ${DATA} -type f -name '*.qp' -delete 
980
                if [[ $? -ne 0 ]];then 
1018
                if [ $? -ne 0 ];then 
981
                    wsrep_log_error "Something went wrong with deletion of qpress files. Investigate"
1019
                    wsrep_log_error "Something went wrong with deletion of qpress files. Investigate"
982
                fi
1020
                fi
983
            else
1021
            else
Lines 987-993 then Link Here
987
        fi
1025
        fi
988
1026
989
1027
990
        if  [[ ! -z $WSREP_SST_OPT_BINLOG ]];then
1028
        if  [ ! -z "$WSREP_SST_OPT_BINLOG" ];then
991
1029
992
            BINLOG_DIRNAME=$(dirname $WSREP_SST_OPT_BINLOG)
1030
            BINLOG_DIRNAME=$(dirname $WSREP_SST_OPT_BINLOG)
993
            BINLOG_FILENAME=$(basename $WSREP_SST_OPT_BINLOG)
1031
            BINLOG_FILENAME=$(basename $WSREP_SST_OPT_BINLOG)
Lines 1018-1024 then Link Here
1018
        set -e
1056
        set -e
1019
        wsrep_log_info "Moving the backup to ${TDATA}"
1057
        wsrep_log_info "Moving the backup to ${TDATA}"
1020
        timeit "Xtrabackup move stage" "$INNOMOVE"
1058
        timeit "Xtrabackup move stage" "$INNOMOVE"
1021
        if [[ $? -eq 0 ]];then 
1059
        if [ $? -eq 0 ];then 
1022
            wsrep_log_info "Move successful, removing ${DATA}"
1060
            wsrep_log_info "Move successful, removing ${DATA}"
1023
            rm -rf $DATA
1061
            rm -rf $DATA
1024
            DATA=${TDATA}
1062
            DATA=${TDATA}
Lines 1033-1039 then Link Here
1033
        wsrep_log_info "${IST_FILE} received from donor: Running IST"
1071
        wsrep_log_info "${IST_FILE} received from donor: Running IST"
1034
    fi
1072
    fi
1035
1073
1036
    if [[ ! -r ${MAGIC_FILE} ]];then 
1074
    if [ ! -r "${MAGIC_FILE}" ];then 
1037
        wsrep_log_error "SST magic file ${MAGIC_FILE} not found/readable"
1075
        wsrep_log_error "SST magic file ${MAGIC_FILE} not found/readable"
1038
        exit 2
1076
        exit 2
1039
    fi
1077
    fi
(-)scripts/wsrep_sst_common.sh (+5 lines)
Lines 28-33 WSREP_SST_OPT_DEFAULT="" Link Here
28
WSREP_SST_OPT_EXTRA_DEFAULT=""
28
WSREP_SST_OPT_EXTRA_DEFAULT=""
29
WSREP_SST_OPT_SUFFIX_DEFAULT=""
29
WSREP_SST_OPT_SUFFIX_DEFAULT=""
30
30
31
# Check to see if we're running bash
32
[ $(ps -o command -p $$ | grep -c bash) -gt 0 ] && shisbash=1
33
# Needed by some scripts
34
OS=$(uname)
35
31
while [ $# -gt 0 ]; do
36
while [ $# -gt 0 ]; do
32
case "$1" in
37
case "$1" in
33
    '--address')
38
    '--address')

Return to bug 229618