Commit 97695675 authored by Julius Goryavsky's avatar Julius Goryavsky

Merge branch 10.2 into 10.3

parents 3376668c b5cbe506
......@@ -28,5 +28,3 @@ query_cache: MDEV-15805 Test failure on galera.query_cache
versioning_trx_id: MDEV-18590: galera.versioning_trx_id: Test failure: mysqltest: Result content mismatch
galera_wsrep_provider_unset_set: wsrep_provider is read-only for security reasons
pxc-421: wsrep_provider is read-only for security reasons
galera_sst_xtrabackup-v2: Test fails due to innodb issues
galera_sst_xtrabackup-v2_data_dir: Test fails due to innodb issues
......@@ -6,10 +6,10 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY);
INSERT INTO t1 VALUES (01), (02), (03), (04), (05);
connection node_2;
Unloading wsrep provider ...
SET GLOBAL wsrep_provider = 'none';
SET GLOBAL wsrep_cluster_address = '';
connection node_3;
Unloading wsrep provider ...
SET GLOBAL wsrep_provider = 'none';
SET GLOBAL wsrep_cluster_address = '';
connection node_1;
INSERT INTO t1 VALUES (11), (12), (13), (14), (15);
INSERT INTO t1 VALUES (21), (22), (23), (24), (25);
......
......@@ -29,9 +29,11 @@ INSERT INTO t1 VALUES (01), (02), (03), (04), (05);
# Disconnect nodes #2 and #3
--connection node_2
--let $wsrep_cluster_address_orig2 = `select @@wsrep_cluster_address`
--source suite/galera/include/galera_stop_replication.inc
--connection node_3
--let $wsrep_cluster_address_orig3 = `select @@wsrep_cluster_address`
--source suite/galera/include/galera_stop_replication.inc
--connection node_1
......@@ -51,8 +53,8 @@ INSERT INTO t1 VALUES (21), (22), (23), (24), (25);
# ... and restart providers to force IST
--connection node_2
--disable_query_log
--eval SET GLOBAL wsrep_provider = '$wsrep_provider_orig';
--eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig';
SET GLOBAL wsrep_cluster_address='';
--eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig2';
--enable_query_log
--connection node_1
......@@ -60,8 +62,8 @@ INSERT INTO t1 VALUES (31), (32), (33), (34), (35);
--connection node_3
--disable_query_log
--eval SET GLOBAL wsrep_provider = '$wsrep_provider_orig';
--eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig';
SET GLOBAL wsrep_cluster_address='';
--eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig3';
--enable_query_log
--connection node_1
......
......@@ -17,7 +17,7 @@
# This is a common command line parser to be sourced by other SST scripts
set -u
set -ue
# Setting the path for some utilities on CentOS
export PATH="$PATH:/usr/sbin:/usr/bin:/sbin:/bin"
......@@ -879,9 +879,9 @@ fi
wsrep_cleanup_progress_file()
{
[ -n "$SST_PROGRESS_FILE" -a \
-f "$SST_PROGRESS_FILE" ] && \
rm -f "$SST_PROGRESS_FILE" 2>/dev/null || :
if [ -n "$SST_PROGRESS_FILE" -a -f "$SST_PROGRESS_FILE" ]; then
rm -f "$SST_PROGRESS_FILE" 2>/dev/null || :
fi
}
wsrep_check_program()
......@@ -897,13 +897,10 @@ wsrep_check_program()
wsrep_check_programs()
{
local ret=0
while [ $# -gt 0 ]
do
while [ $# -gt 0 ]; do
wsrep_check_program "$1" || ret=$?
shift
done
return $ret
}
......@@ -1028,11 +1025,11 @@ check_sockets_utils()
#
check_port()
{
local pid="$1"
local pid="${1:-0}"
local port="$2"
local utils="$3"
[ -z "$pid" ] || [ $pid -eq 0 ] && pid='[0-9]+'
[ $pid -le 0 ] && pid='[0-9]+'
local rc=1
......@@ -1070,14 +1067,20 @@ check_for_dhparams()
if [ ! -r "$ssl_dhparams" ]; then
get_openssl
if [ -n "$OPENSSL_BINARY" ]; then
wsrep_log_info "Could not find dhparams file, creating $ssl_dhparams"
if ! "$OPENSSL_BINARY" dhparam -out "$ssl_dhparams" 2048 >/dev/null 2>&1
then
wsrep_log_info \
"Could not find dhparams file, creating $ssl_dhparams"
local bug=0
local errmsg
errmsg=$("$OPENSSL_BINARY" \
dhparam -out "$ssl_dhparams" 2048 2>&1) || bug=1
if [ $bug -ne 0 ]; then
wsrep_log_info "run: \"$OPENSSL_BINARY\" dhparam -out \"$ssl_dhparams\" 2048"
wsrep_log_info "output: $errmsg"
wsrep_log_error "******** ERROR *****************************************"
wsrep_log_error "* Could not create the dhparams.pem file with OpenSSL. *"
wsrep_log_error "********************************************************"
ssl_dhparams=""
fi
fi
else
# Rollback: if openssl is not installed, then use
# the default parameters:
......@@ -1099,17 +1102,9 @@ verify_ca_matches_cert()
local ca="$2"
local cap="$3"
# If the openssl utility is not installed, then
# we will not do this certificate check:
get_openssl
if [ -z "$OPENSSL_BINARY" ]; then
wsrep_log_info "openssl utility not found"
return
fi
local readable=1; [ ! -r "$cert" ] && readable=0
[ -n "$ca" ] && [ ! -r "$ca" ] && readable=0
[ -n "$cap" ] && [ ! -r "$cap" ] && readable=0
[ -n "$ca" -a ! -r "$ca" ] && readable=0
[ -n "$cap" -a ! -r "$cap" ] && readable=0
if [ $readable -eq 0 ]; then
wsrep_log_error \
......@@ -1117,12 +1112,20 @@ verify_ca_matches_cert()
exit 22
fi
# If the openssl utility is not installed, then
# we will not do this certificate check:
get_openssl
if [ -z "$OPENSSL_BINARY" ]; then
wsrep_log_info "openssl utility not found"
return
fi
local not_match=0
local errmsg
errmsg=$("$OPENSSL_BINARY" verify -verbose \
${ca:+ -CAfile} ${ca:+ "$ca"} \
${cap:+ -CApath} ${cap:+ "$cap"} \
"$cert" 2>&1) || not_match=1
${ca:+ -CAfile} ${ca:+ "$ca"} \
${cap:+ -CApath} ${cap:+ "$cap"} \
"$cert" 2>&1) || not_match=1
if [ $not_match -eq 1 ]; then
wsrep_log_info "run: \"$OPENSSL_BINARY\" verify -verbose${ca:+ -CAfile \"$ca\"}${cap:+ -CApath \"$cap\"} \"$cert\""
......@@ -1158,6 +1161,7 @@ verify_cert_matches_key()
# If the diff utility is not installed, then
# we will not do this certificate check:
if [ -z "$(commandex diff)" ]; then
wsrep_log_info "diff utility not found"
return
fi
......@@ -1165,6 +1169,7 @@ verify_cert_matches_key()
# we will not do this certificate check:
get_openssl
if [ -z "$OPENSSL_BINARY" ]; then
wsrep_log_info "openssl utility not found"
return
fi
......@@ -1253,18 +1258,18 @@ check_pid()
{
local pid_file="$1"
if [ -r "$pid_file" ]; then
local pid=$(cat "$pid_file" 2>/dev/null)
local pid=$(cat "$pid_file" 2>/dev/null || :)
if [ -n "$pid" ]; then
if [ $pid -ne 0 ]; then
if ps -p "$pid" >/dev/null 2>&1; then
if [ $pid -gt 0 ]; then
if ps -p $pid >/dev/null 2>&1; then
CHECK_PID=$pid
return 0
fi
fi
fi
local remove=${2:-0}
if [ $remove -eq 1 ]; then
rm -f "$pid_file"
if [ $remove -ne 0 ]; then
rm -f "$pid_file" || :
fi
fi
CHECK_PID=0
......@@ -1289,25 +1294,25 @@ cleanup_pid()
local pid_file="${2:-}"
local config="${3:-}"
if [ $pid -ne 0 ]; then
if [ $pid -gt 0 ]; then
if ps -p $pid >/dev/null 2>&1; then
if kill $pid >/dev/null 2>&1; then
sleep 0.5
local round=0
local force=0
while ps -p $pid >/dev/null 2>&1; do
sleep 1
round=$(( round+1 ))
if [ $round -eq 16 ]; then
if [ $force -eq 0 ]; then
round=8
force=1
kill -9 $pid >/dev/null 2>&1
sleep 0.5
else
return 1
fi
fi
sleep 1
round=$(( round+1 ))
if [ $round -eq 16 ]; then
if [ $force -eq 0 ]; then
round=8
force=1
kill -9 $pid >/dev/null 2>&1 || :
sleep 0.5
else
return 1
fi
fi
done
elif ps -p $pid >/dev/null 2>&1; then
wsrep_log_warning "Unable to kill PID=$pid ($pid_file)"
......@@ -1316,8 +1321,8 @@ cleanup_pid()
fi
fi
[ -n "$pid_file" ] && [ -f "$pid_file" ] && rm -f "$pid_file"
[ -n "$config" ] && [ -f "$config" ] && rm -f "$config"
[ -n "$pid_file" -a -f "$pid_file" ] && rm -f "$pid_file" || :
[ -n "$config" -a -f "$config" ] && rm -f "$config" || :
return 0
}
......@@ -1339,3 +1344,46 @@ get_proc()
fi
fi
}
check_server_ssl_config()
{
# backward-compatible behavior:
tcert=$(parse_cnf 'sst' 'tca')
tcap=$(parse_cnf 'sst' 'tcapath')
tpem=$(parse_cnf 'sst' 'tcert')
tkey=$(parse_cnf 'sst' 'tkey')
# reading new ssl configuration options:
local tcert2=$(parse_cnf "$encgroups" 'ssl-ca')
local tcap2=$(parse_cnf "$encgroups" 'ssl-capath')
local tpem2=$(parse_cnf "$encgroups" 'ssl-cert')
local tkey2=$(parse_cnf "$encgroups" 'ssl-key')
# if there are no old options, then we take new ones:
if [ -z "$tcert" -a -z "$tcap" -a -z "$tpem" -a -z "$tkey" ]; then
tcert="$tcert2"
tcap="$tcap2"
tpem="$tpem2"
tkey="$tkey2"
# checking for presence of the new-style SSL configuration:
elif [ -n "$tcert2" -o -n "$tcap2" -o -n "$tpem2" -o -n "$tkey2" ]; then
if [ "$tcert" != "$tcert2" -o \
"$tcap" != "$tcap2" -o \
"$tpem" != "$tpem2" -o \
"$tkey" != "$tkey2" ]
then
wsrep_log_info \
"new ssl configuration options (ssl-ca[path], ssl-cert" \
"and ssl-key) are ignored by SST due to presence" \
"of the tca[path], tcert and/or tkey in the [sst] section"
fi
fi
if [ -n "$tcert" ]; then
tcert=$(trim_string "$tcert")
if [ "${tcert%/}" != "$tcert" -o -d "$tcert" ]; then
tcap="$tcert"
tcert=""
fi
fi
if [ -n "$tcap" ]; then
tcap=$(trim_string "$tcap")
fi
}
......@@ -30,7 +30,6 @@ eformat=""
ekey=""
ekeyfile=""
encrypt=0
ecode=0
ssyslog=""
ssystag=""
BACKUP_PID=""
......@@ -465,49 +464,6 @@ adjust_progress()
encgroups='--mysqld|sst|xtrabackup'
check_server_ssl_config()
{
# backward-compatible behavior:
tcert=$(parse_cnf 'sst' 'tca')
tcap=$(parse_cnf 'sst' 'tcapath')
tpem=$(parse_cnf 'sst' 'tcert')
tkey=$(parse_cnf 'sst' 'tkey')
# reading new ssl configuration options:
local tcert2=$(parse_cnf "$encgroups" 'ssl-ca')
local tcap2=$(parse_cnf "$encgroups" 'ssl-capath')
local tpem2=$(parse_cnf "$encgroups" 'ssl-cert')
local tkey2=$(parse_cnf "$encgroups" 'ssl-key')
# if there are no old options, then we take new ones:
if [ -z "$tcert" -a -z "$tcap" -a -z "$tpem" -a -z "$tkey" ]; then
tcert="$tcert2"
tcap="$tcap2"
tpem="$tpem2"
tkey="$tkey2"
# checking for presence of the new-style SSL configuration:
elif [ -n "$tcert2" -o -n "$tcap2" -o -n "$tpem2" -o -n "$tkey2" ]; then
if [ "$tcert" != "$tcert2" -o \
"$tcap" != "$tcap2" -o \
"$tpem" != "$tpem2" -o \
"$tkey" != "$tkey2" ]
then
wsrep_log_info \
"new ssl configuration options (ssl-ca[path], ssl-cert" \
"and ssl-key) are ignored by SST due to presence" \
"of the tca[path], tcert and/or tkey in the [sst] section"
fi
fi
if [ -n "$tcert" ]; then
tcert=$(trim_string "$tcert")
if [ "${tcert%/}" != "$tcert" ] || [ -d "$tcert" ]; then
tcap="$tcert"
tcert=""
fi
fi
if [ -n "$tcap" ]; then
tcap=$(trim_string "$tcap")
fi
}
read_cnf()
{
sfmt=$(parse_cnf sst streamfmt 'mbstream')
......@@ -647,7 +603,7 @@ cleanup_at_exit()
cleanup_pid $CHECK_PID "$BACKUP_PID"
fi
fi
[ -f "$DATA/$IST_FILE" ] && rm -f "$DATA/$IST_FILE"
[ -f "$DATA/$IST_FILE" ] && rm -f "$DATA/$IST_FILE" || :
fi
if [ -n "$progress" -a -p "$progress" ]; then
......@@ -658,27 +614,31 @@ cleanup_at_exit()
wsrep_log_info "Cleaning up temporary directories"
if [ "$WSREP_SST_OPT_ROLE" = 'joiner' ]; then
if [ -n "$STATDIR" ]; then
[ -d "$STATDIR" ] && rm -rf "$STATDIR"
fi
[ -n "$STATDIR" -a -d "$STATDIR" ] && rm -rf "$STATDIR" || :
else
[ -n "$xtmpdir" -a -d "$xtmpdir" ] && rm -rf "$xtmpdir" || :
[ -n "$itmpdir" -a -d "$itmpdir" ] && rm -rf "$itmpdir" || :
fi
# Final cleanup
pgid=$(ps -o pgid= $$ | grep -o '[0-9]*')
pgid=$(ps -o pgid= $$ 2>/dev/null | grep -o '[0-9]*' || :)
# This means no setsid done in mysqld.
# We don't want to kill mysqld here otherwise.
if [ $$ -eq $pgid ]; then
# This means a signal was delivered to the process.
# So, more cleanup.
if [ $estatus -ge 128 ]; then
kill -KILL -- -$$ || :
if [ -n "$pgid" ]; then
if [ $$ -eq $pgid ]; then
# This means a signal was delivered to the process.
# So, more cleanup.
if [ $estatus -ge 128 ]; then
kill -KILL -- -$$ || :
fi
fi
fi
if [ -n "${SST_PID:-}" ]; then
[ -f "$SST_PID" ] && rm -f "$SST_PID" || :
fi
exit $estatus
}
......@@ -967,7 +927,7 @@ setup_commands()
fi
INNOAPPLY="$BACKUP_BIN --prepare$disver$recovery${iapts:+ }$iapts$INNOEXTRA --target-dir='$DATA' --datadir='$DATA'$mysqld_args $INNOAPPLY"
INNOMOVE="$BACKUP_BIN$WSREP_SST_OPT_CONF --move-back$disver${impts:+ }$impts --force-non-empty-directories --target-dir='$DATA' --datadir='${TDATA:-$DATA}' $INNOMOVE"
INNOBACKUP="$BACKUP_BIN$WSREP_SST_OPT_CONF --backup$disver${iopts:+ }$iopts $tmpopts$INNOEXTRA --galera-info --stream=$sfmt --target-dir='$itmpdir' --datadir='$DATA'$mysqld_args $INNOBACKUP"
INNOBACKUP="$BACKUP_BIN$WSREP_SST_OPT_CONF --backup$disver${iopts:+ }$iopts$tmpopts$INNOEXTRA --galera-info --stream=$sfmt --target-dir='$itmpdir' --datadir='$DATA'$mysqld_args $INNOBACKUP"
}
get_stream
......@@ -995,7 +955,7 @@ then
fi
wsrep_log_info "Using '$xtmpdir' as mariabackup temporary directory"
tmpopts="--tmpdir='$xtmpdir'"
tmpopts=" --tmpdir='$xtmpdir'"
itmpdir="$(mktemp -d)"
wsrep_log_info "Using '$itmpdir' as mariabackup working directory"
......@@ -1161,10 +1121,23 @@ then
impts="--parallel=$backup_threads${impts:+ }$impts"
fi
stagemsg='Joiner-Recv'
SST_PID="$WSREP_SST_OPT_DATA/wsrep_sst.pid"
# give some time for previous SST to complete:
check_round=0
while check_pid "$SST_PID" 0; do
wsrep_log_info "previous SST is not completed, waiting for it to exit"
check_round=$(( check_round + 1 ))
if [ $check_round -eq 10 ]; then
wsrep_log_error "previous SST script still running."
exit 114 # EALREADY
fi
sleep 1
done
echo $$ > "$SST_PID"
sencrypted=1
nthreads=1
stagemsg='Joiner-Recv'
MODULE="xtrabackup_sst"
......@@ -1208,7 +1181,7 @@ then
fi
get_keys
if [ $encrypt -eq 1 -a $sencrypted -eq 1 ]; then
if [ $encrypt -eq 1 ]; then
strmcmd="$ecmd | $strmcmd"
fi
......@@ -1263,12 +1236,14 @@ then
if [ -n "$WSREP_SST_OPT_BINLOG" ]; then
binlog_dir=$(dirname "$WSREP_SST_OPT_BINLOG")
cd "$binlog_dir"
wsrep_log_info "Cleaning the binlog directory $binlog_dir as well"
rm -fv "$WSREP_SST_OPT_BINLOG".[0-9]* 1>&2 \+ || :
[ -f "$WSREP_SST_OPT_BINLOG_INDEX" ] && \
rm -fv "$WSREP_SST_OPT_BINLOG_INDEX" 1>&2 \+ || :
cd "$OLD_PWD"
if [ -d "$binlog_dir" ]; then
cd "$binlog_dir"
wsrep_log_info "Cleaning the binlog directory $binlog_dir as well"
rm -fv "$WSREP_SST_OPT_BINLOG".[0-9]* 1>&2 \+ || :
[ -f "$WSREP_SST_OPT_BINLOG_INDEX" ] && \
rm -fv "$WSREP_SST_OPT_BINLOG_INDEX" 1>&2 \+
cd "$OLD_PWD"
fi
fi
TDATA="$DATA"
......@@ -1285,7 +1260,7 @@ then
fi
# Compact backups are not supported by mariabackup
if grep -q -F 'compact = 1' "$DATA/xtrabackup_checkpoints"; then
if grep -qw -F 'compact = 1' "$DATA/xtrabackup_checkpoints"; then
wsrep_log_info "Index compaction detected"
wsrel_log_error "Compact backups are not supported by mariabackup"
exit 2
......
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