Commit 2ba1a8b8 authored by Julius Goryavsky's avatar Julius Goryavsky

MDEV-31809 addendum: corrections for SST scripts and for test failures

parent a1e5a284
!include ../galera_2nodes.cnf !include ../galera_2nodes.cnf
[mysqld]
wsrep_sst_auth="root:"
[mysqld.1] [mysqld.1]
wsrep_provider_options='base_port=@mysqld.1.#galera_port;gmcast.segment=1' wsrep_provider_options='base_port=@mysqld.1.#galera_port;gmcast.segment=1'
......
...@@ -152,7 +152,6 @@ WSREP_SST_OPT_DATA="" ...@@ -152,7 +152,6 @@ WSREP_SST_OPT_DATA=""
WSREP_SST_OPT_AUTH="${WSREP_SST_OPT_AUTH:-}" WSREP_SST_OPT_AUTH="${WSREP_SST_OPT_AUTH:-}"
WSREP_SST_OPT_USER="${WSREP_SST_OPT_USER:-}" WSREP_SST_OPT_USER="${WSREP_SST_OPT_USER:-}"
WSREP_SST_OPT_PSWD="${WSREP_SST_OPT_PSWD:-}" WSREP_SST_OPT_PSWD="${WSREP_SST_OPT_PSWD:-}"
WSREP_SST_OPT_REMOTE_AUTH="${WSREP_SST_OPT_REMOTE_AUTH:-}"
WSREP_SST_OPT_DEFAULT="" WSREP_SST_OPT_DEFAULT=""
WSREP_SST_OPT_DEFAULTS="" WSREP_SST_OPT_DEFAULTS=""
WSREP_SST_OPT_EXTRA_DEFAULT="" WSREP_SST_OPT_EXTRA_DEFAULT=""
...@@ -1008,11 +1007,6 @@ in_config() ...@@ -1008,11 +1007,6 @@ in_config()
echo $found echo $found
} }
wsrep_auth_not_set()
{
[ -z "$WSREP_SST_OPT_AUTH" ]
}
# Get rid of incorrect values resulting from substitution # Get rid of incorrect values resulting from substitution
# in programs external to the script: # in programs external to the script:
if [ "$WSREP_SST_OPT_USER" = '(null)' ]; then if [ "$WSREP_SST_OPT_USER" = '(null)' ]; then
...@@ -1028,12 +1022,12 @@ fi ...@@ -1028,12 +1022,12 @@ fi
# Let's read the value of the authentication string from the # Let's read the value of the authentication string from the
# configuration file so that it does not go to the command line # configuration file so that it does not go to the command line
# and does not appear in the ps output: # and does not appear in the ps output:
if wsrep_auth_not_set; then if [ -z "$WSREP_SST_OPT_AUTH" ]; then
WSREP_SST_OPT_AUTH=$(parse_cnf 'sst' 'wsrep-sst-auth') WSREP_SST_OPT_AUTH=$(parse_cnf 'sst' 'wsrep-sst-auth')
fi fi
# Splitting WSREP_SST_OPT_AUTH as "user:password" pair: # Splitting WSREP_SST_OPT_AUTH as "user:password" pair:
if ! wsrep_auth_not_set; then if [ -n "$WSREP_SST_OPT_AUTH" ]; then
# Extract username as shortest prefix up to first ':' character: # Extract username as shortest prefix up to first ':' character:
WSREP_SST_OPT_AUTH_USER="${WSREP_SST_OPT_AUTH%%:*}" WSREP_SST_OPT_AUTH_USER="${WSREP_SST_OPT_AUTH%%:*}"
if [ -z "$WSREP_SST_OPT_USER" ]; then if [ -z "$WSREP_SST_OPT_USER" ]; then
...@@ -1057,12 +1051,13 @@ if ! wsrep_auth_not_set; then ...@@ -1057,12 +1051,13 @@ if ! wsrep_auth_not_set; then
fi fi
fi fi
WSREP_SST_OPT_REMOTE_AUTH="${WSREP_SST_OPT_REMOTE_AUTH:-}"
WSREP_SST_OPT_REMOTE_USER= WSREP_SST_OPT_REMOTE_USER=
WSREP_SST_OPT_REMOTE_PSWD= WSREP_SST_OPT_REMOTE_PSWD=
if [ -n "$WSREP_SST_OPT_REMOTE_AUTH" ]; then if [ -n "$WSREP_SST_OPT_REMOTE_AUTH" ]; then
# Split auth string at the last ':' # Split auth string at the last ':'
readonly WSREP_SST_OPT_REMOTE_USER="${WSREP_SST_OPT_REMOTE_AUTH%%:*}" WSREP_SST_OPT_REMOTE_USER="${WSREP_SST_OPT_REMOTE_AUTH%%:*}"
readonly WSREP_SST_OPT_REMOTE_PSWD="${WSREP_SST_OPT_REMOTE_AUTH#*:}" WSREP_SST_OPT_REMOTE_PSWD="${WSREP_SST_OPT_REMOTE_AUTH#*:}"
fi fi
# Reads incoming data from STDIN and sets the variables # Reads incoming data from STDIN and sets the variables
...@@ -1077,8 +1072,9 @@ fi ...@@ -1077,8 +1072,9 @@ fi
read_variables_from_stdin() read_variables_from_stdin()
{ {
while read line; do while read line; do
key=${line%%=*} local key="${line%%=*}"
value=${line#*=} local value=""
[ "$key" != "$line" ] && value="${line#*=}"
case "$key" in case "$key" in
'sst_user') 'sst_user')
WSREP_SST_OPT_USER="$value" WSREP_SST_OPT_USER="$value"
......
...@@ -1098,15 +1098,13 @@ if [ "$WSREP_SST_OPT_ROLE" = 'donor' ]; then ...@@ -1098,15 +1098,13 @@ if [ "$WSREP_SST_OPT_ROLE" = 'donor' ]; then
itmpdir="$(mktemp -d)" itmpdir="$(mktemp -d)"
wsrep_log_info "Using '$itmpdir' as mariadb-abackup working directory" wsrep_log_info "Using '$itmpdir' as mariadb-abackup working directory"
usrst=0
if [ -n "$WSREP_SST_OPT_USER" ]; then if [ -n "$WSREP_SST_OPT_USER" ]; then
INNOEXTRA="$INNOEXTRA --user='$WSREP_SST_OPT_USER'" INNOEXTRA="$INNOEXTRA --user='$WSREP_SST_OPT_USER'"
usrst=1
fi fi
if [ -n "$WSREP_SST_OPT_PSWD" ]; then if [ -n "$WSREP_SST_OPT_PSWD" ]; then
export MYSQL_PWD="$WSREP_SST_OPT_PSWD" export MYSQL_PWD="$WSREP_SST_OPT_PSWD"
elif [ $usrst -eq 1 ]; then elif [ -n "$WSREP_SST_OPT_USER" ]; then
# Empty password, used for testing, debugging etc. # Empty password, used for testing, debugging etc.
unset MYSQL_PWD unset MYSQL_PWD
fi fi
......
...@@ -47,10 +47,19 @@ if ! $MYSQL_CLIENT --version | grep -q -E '(Distrib 10\.[1-9])|( from 1[1-9]\.)' ...@@ -47,10 +47,19 @@ if ! $MYSQL_CLIENT --version | grep -q -E '(Distrib 10\.[1-9])|( from 1[1-9]\.)'
fi fi
AUTH="" AUTH=""
usrst=0
if [ -n "$WSREP_SST_OPT_USER" ]; then if [ -n "$WSREP_SST_OPT_USER" ]; then
AUTH="-u$WSREP_SST_OPT_USER" AUTH="-u$WSREP_SST_OPT_USER"
usrst=1 fi
# Both donor and joiner must have the same wsrep_sst_auth
# configuration and different (and thus automatically generated)
# authentication credentials can't be used for this type of SST.
# In this case the SST will fail if joiner does not provide
# correct authentication.
REMOTE_AUTH="$AUTH"
if [ -n "$WSREP_SST_OPT_REMOTE_USER" ]; then
REMOTE_AUTH="-u$WSREP_SST_OPT_REMOTE_USER"
[ -z "$AUTH" ] && AUTH="$REMOTE_AUTH"
fi fi
# Refs https://github.com/codership/mysql-wsrep/issues/141 # Refs https://github.com/codership/mysql-wsrep/issues/141
...@@ -64,19 +73,16 @@ fi ...@@ -64,19 +73,16 @@ fi
# word, it is arguably more secure than passing password on the command line. # word, it is arguably more secure than passing password on the command line.
if [ -n "$WSREP_SST_OPT_REMOTE_PSWD" ]; then if [ -n "$WSREP_SST_OPT_REMOTE_PSWD" ]; then
export MYSQL_PWD="$WSREP_SST_OPT_REMOTE_PSWD" export MYSQL_PWD="$WSREP_SST_OPT_REMOTE_PSWD"
elif [ $usrst -eq 1 ]; then elif [ -n "$WSREP_SST_OPT_REMOTE_USER" ]; then
# Empty password, used for testing, debugging etc.
unset MYSQL_PWD
elif [ -n "$WSREP_SST_OPT_PSWD" ]; then
export MYSQL_PWD="$WSREP_SST_OPT_PSWD"
elif [ -n "$WSREP_SST_OPT_USER" ]; then
# Empty password, used for testing, debugging etc. # Empty password, used for testing, debugging etc.
unset MYSQL_PWD unset MYSQL_PWD
fi fi
# The above also means that both donor and joiner must have the same
# wsrep_sst_auth configuration and and different (and thus automatically
# generated) authentication credentials can't be used for this type of SST
# In this case the SST will fail if joiner does not provide correct
# authentication.
[ -n "$WSREP_SST_OPT_REMOTE_USER" ] && REMOTE_AUTH="-u$WSREP_SST_OPT_REMOTE_USER" || REMOTE_AUTH=
[ -n "$REMOTE_AUTH" ] && AUTH="$REMOTE_AUTH" || AUTH=
STOP_WSREP='SET wsrep_on=OFF;' STOP_WSREP='SET wsrep_on=OFF;'
# mysqldump cannot restore CSV tables, fix this issue # mysqldump cannot restore CSV tables, fix this issue
......
...@@ -1576,7 +1576,9 @@ wsrep_sst_cleanup_user(THD* const thd) ...@@ -1576,7 +1576,9 @@ wsrep_sst_cleanup_user(THD* const thd)
if ((err = mysql.errnum()) || if ((err = mysql.errnum()) ||
(err = mysql.disable_replication()) || (err = mysql.disable_replication()) ||
((err = mysql.execute("DELETE FROM mysql.user WHERE user LIKE '" SST_USER_PREFIX "%';")) && ((err = mysql.execute("DELETE FROM mysql.user WHERE user LIKE '" SST_USER_PREFIX "%';")) &&
err != ER_NO_SUCH_TABLE)) { err != ER_NO_SUCH_TABLE &&
err != ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE))
{
WSREP_WARN("Failed to clean up SST user(s): %d (%s)", err, mysql.errstr()); WSREP_WARN("Failed to clean up SST user(s): %d (%s)", err, mysql.errstr());
} }
} }
......
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