Skip to content

Commit 2ba1a8b

Browse files
committed
MDEV-31809 addendum: corrections for SST scripts and for test failures
1 parent a1e5a28 commit 2ba1a8b

File tree

5 files changed

+32
-27
lines changed

5 files changed

+32
-27
lines changed

mysql-test/suite/galera/t/galera_defaults.cnf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
!include ../galera_2nodes.cnf
22

3+
[mysqld]
4+
wsrep_sst_auth="root:"
5+
36
[mysqld.1]
47
wsrep_provider_options='base_port=@mysqld.1.#galera_port;gmcast.segment=1'
58

scripts/wsrep_sst_common.sh

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ WSREP_SST_OPT_DATA=""
152152
WSREP_SST_OPT_AUTH="${WSREP_SST_OPT_AUTH:-}"
153153
WSREP_SST_OPT_USER="${WSREP_SST_OPT_USER:-}"
154154
WSREP_SST_OPT_PSWD="${WSREP_SST_OPT_PSWD:-}"
155-
WSREP_SST_OPT_REMOTE_AUTH="${WSREP_SST_OPT_REMOTE_AUTH:-}"
156155
WSREP_SST_OPT_DEFAULT=""
157156
WSREP_SST_OPT_DEFAULTS=""
158157
WSREP_SST_OPT_EXTRA_DEFAULT=""
@@ -1008,11 +1007,6 @@ in_config()
10081007
echo $found
10091008
}
10101009

1011-
wsrep_auth_not_set()
1012-
{
1013-
[ -z "$WSREP_SST_OPT_AUTH" ]
1014-
}
1015-
10161010
# Get rid of incorrect values resulting from substitution
10171011
# in programs external to the script:
10181012
if [ "$WSREP_SST_OPT_USER" = '(null)' ]; then
@@ -1028,12 +1022,12 @@ fi
10281022
# Let's read the value of the authentication string from the
10291023
# configuration file so that it does not go to the command line
10301024
# and does not appear in the ps output:
1031-
if wsrep_auth_not_set; then
1025+
if [ -z "$WSREP_SST_OPT_AUTH" ]; then
10321026
WSREP_SST_OPT_AUTH=$(parse_cnf 'sst' 'wsrep-sst-auth')
10331027
fi
10341028

10351029
# Splitting WSREP_SST_OPT_AUTH as "user:password" pair:
1036-
if ! wsrep_auth_not_set; then
1030+
if [ -n "$WSREP_SST_OPT_AUTH" ]; then
10371031
# Extract username as shortest prefix up to first ':' character:
10381032
WSREP_SST_OPT_AUTH_USER="${WSREP_SST_OPT_AUTH%%:*}"
10391033
if [ -z "$WSREP_SST_OPT_USER" ]; then
@@ -1057,12 +1051,13 @@ if ! wsrep_auth_not_set; then
10571051
fi
10581052
fi
10591053

1054+
WSREP_SST_OPT_REMOTE_AUTH="${WSREP_SST_OPT_REMOTE_AUTH:-}"
10601055
WSREP_SST_OPT_REMOTE_USER=
10611056
WSREP_SST_OPT_REMOTE_PSWD=
10621057
if [ -n "$WSREP_SST_OPT_REMOTE_AUTH" ]; then
10631058
# Split auth string at the last ':'
1064-
readonly WSREP_SST_OPT_REMOTE_USER="${WSREP_SST_OPT_REMOTE_AUTH%%:*}"
1065-
readonly WSREP_SST_OPT_REMOTE_PSWD="${WSREP_SST_OPT_REMOTE_AUTH#*:}"
1059+
WSREP_SST_OPT_REMOTE_USER="${WSREP_SST_OPT_REMOTE_AUTH%%:*}"
1060+
WSREP_SST_OPT_REMOTE_PSWD="${WSREP_SST_OPT_REMOTE_AUTH#*:}"
10661061
fi
10671062

10681063
# Reads incoming data from STDIN and sets the variables
@@ -1077,8 +1072,9 @@ fi
10771072
read_variables_from_stdin()
10781073
{
10791074
while read line; do
1080-
key=${line%%=*}
1081-
value=${line#*=}
1075+
local key="${line%%=*}"
1076+
local value=""
1077+
[ "$key" != "$line" ] && value="${line#*=}"
10821078
case "$key" in
10831079
'sst_user')
10841080
WSREP_SST_OPT_USER="$value"

scripts/wsrep_sst_mariabackup.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,15 +1098,13 @@ if [ "$WSREP_SST_OPT_ROLE" = 'donor' ]; then
10981098
itmpdir="$(mktemp -d)"
10991099
wsrep_log_info "Using '$itmpdir' as mariadb-abackup working directory"
11001100

1101-
usrst=0
11021101
if [ -n "$WSREP_SST_OPT_USER" ]; then
11031102
INNOEXTRA="$INNOEXTRA --user='$WSREP_SST_OPT_USER'"
1104-
usrst=1
11051103
fi
11061104

11071105
if [ -n "$WSREP_SST_OPT_PSWD" ]; then
11081106
export MYSQL_PWD="$WSREP_SST_OPT_PSWD"
1109-
elif [ $usrst -eq 1 ]; then
1107+
elif [ -n "$WSREP_SST_OPT_USER" ]; then
11101108
# Empty password, used for testing, debugging etc.
11111109
unset MYSQL_PWD
11121110
fi

scripts/wsrep_sst_mysqldump.sh

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,19 @@ if ! $MYSQL_CLIENT --version | grep -q -E '(Distrib 10\.[1-9])|( from 1[1-9]\.)'
4747
fi
4848

4949
AUTH=""
50-
usrst=0
5150
if [ -n "$WSREP_SST_OPT_USER" ]; then
5251
AUTH="-u$WSREP_SST_OPT_USER"
53-
usrst=1
52+
fi
53+
54+
# Both donor and joiner must have the same wsrep_sst_auth
55+
# configuration and different (and thus automatically generated)
56+
# authentication credentials can't be used for this type of SST.
57+
# In this case the SST will fail if joiner does not provide
58+
# correct authentication.
59+
REMOTE_AUTH="$AUTH"
60+
if [ -n "$WSREP_SST_OPT_REMOTE_USER" ]; then
61+
REMOTE_AUTH="-u$WSREP_SST_OPT_REMOTE_USER"
62+
[ -z "$AUTH" ] && AUTH="$REMOTE_AUTH"
5463
fi
5564

5665
# Refs https://github.com/codership/mysql-wsrep/issues/141
@@ -64,19 +73,16 @@ fi
6473
# word, it is arguably more secure than passing password on the command line.
6574
if [ -n "$WSREP_SST_OPT_REMOTE_PSWD" ]; then
6675
export MYSQL_PWD="$WSREP_SST_OPT_REMOTE_PSWD"
67-
elif [ $usrst -eq 1 ]; then
76+
elif [ -n "$WSREP_SST_OPT_REMOTE_USER" ]; then
77+
# Empty password, used for testing, debugging etc.
78+
unset MYSQL_PWD
79+
elif [ -n "$WSREP_SST_OPT_PSWD" ]; then
80+
export MYSQL_PWD="$WSREP_SST_OPT_PSWD"
81+
elif [ -n "$WSREP_SST_OPT_USER" ]; then
6882
# Empty password, used for testing, debugging etc.
6983
unset MYSQL_PWD
7084
fi
7185

72-
# The above also means that both donor and joiner must have the same
73-
# wsrep_sst_auth configuration and and different (and thus automatically
74-
# generated) authentication credentials can't be used for this type of SST
75-
# In this case the SST will fail if joiner does not provide correct
76-
# authentication.
77-
[ -n "$WSREP_SST_OPT_REMOTE_USER" ] && REMOTE_AUTH="-u$WSREP_SST_OPT_REMOTE_USER" || REMOTE_AUTH=
78-
[ -n "$REMOTE_AUTH" ] && AUTH="$REMOTE_AUTH" || AUTH=
79-
8086
STOP_WSREP='SET wsrep_on=OFF;'
8187

8288
# mysqldump cannot restore CSV tables, fix this issue

sql/wsrep_sst.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,9 @@ wsrep_sst_cleanup_user(THD* const thd)
15761576
if ((err = mysql.errnum()) ||
15771577
(err = mysql.disable_replication()) ||
15781578
((err = mysql.execute("DELETE FROM mysql.user WHERE user LIKE '" SST_USER_PREFIX "%';")) &&
1579-
err != ER_NO_SUCH_TABLE)) {
1579+
err != ER_NO_SUCH_TABLE &&
1580+
err != ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE))
1581+
{
15801582
WSREP_WARN("Failed to clean up SST user(s): %d (%s)", err, mysql.errstr());
15811583
}
15821584
}

0 commit comments

Comments
 (0)