2022-02-03 12:06:25 +00:00
#!/usr/bin/env bash
set -ue
2015-06-06 01:08:41 +03:00
# Copyright (C) 2009-2015 Codership Oy
2024-09-15 04:27:23 +02:00
# Copyright (C) 2017-2024 MariaDB
2014-08-06 15:39:15 +03:00
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to the
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston
2019-05-11 22:19:05 +03:00
# MA 02110-1335 USA.
2014-08-06 15:39:15 +03:00
2024-09-16 16:39:59 +02:00
# This is a reference script for mariadb-dump-based state snapshot tansfer.
2014-08-06 15:39:15 +03:00
MDEV-23580: WSREP_SST: [ERROR] rsync daemon port has been taken
This commit contains a large set of further bug fixes and
improvements to SST scripts for Galera, continuing the work
that was started in MDEV-24962 to make SST scripts work smoothly
in different network configurations (especially using ipv6) and
with different environment settings:
1) The ipv6 addresses were incorrectly handled in the SST script
for rsync (incorrect address substitution for establishing a
connection, incorrect address substitution for bind, and so on);
2) Checking the locality of the ip-address in SST scripts did not
support ipv6 addresses (such as "[::1]"), which were falsely
identified as non-local ip, which further did not allow running
two SSTs on different local addresses on the same machine.
On the other hand, this bug masked some other errors (related
to handling ipv6 addresses);
3) The code for checking the locality of the ip address was different
in the SST scripts for rsync and for mysqldump, with individual
flaws. This code is now made common and moved to wsrep_sst_common;
4) Waiting for the start of the transport channel (socat, nc, rsync,
stunnel) in the wait_for_listen() and check_pid_and_port() functions
did not process ipv6 addresses correctly in all cases (not for all
branches);
5) Waiting for the start of the transport channel (socat, nc, rsync,
stunnel) in the wait_for_listen() and check_pid_and_port() functions
for some code branches could give a false positive result due to
the textual match of prefixes in the port number and/or PID of
the process;
6) Waiting for the start of the transport channel (socat, nc, rsync,
stunnel) was supported through different utilities in SST scripts
for mariabackup and for rsync, and with various minor flaws in
the code. Now the code is still different in these scripts, but
it supports a common set of utilities (lsof, ss, sockstat) and
is synchronized across patterns that used to check the output
of these utilities;
7) In SST via mariabackup, the signal about readiness to receive data
is sometimes sent too early - immediately after listen(), and not
after accept() (which are called by socat or netcat utility).
8) Checking availability of the some options of some utilities was
done using the grep pattern, which easily gives false positives;
9) Common name (CN) for local addresses, if not explicitly specified,
is now always replaced to "localhost" to avoid the need to generate
many separate certificates for local addresses of one machine and
not to depend on which the local address is currently used in test
(ipv4 or ipv6, etc.);
10) In tests galera_sst_mariabackup_encrypt_with_key_server and
galera_sst_rsync_encrypt_with_key_server the correct certificate
is selected to avoid commonname (CN) mismatch problems;
11) Further refactoring to protect against spaces in file names.
12) Further general refactoring to eliminate bash-specific constructs
or to improve code readability;
13) The code for setting options for the nc (netcat) utility was
different in different scripts for SST - now it is made identical.
14) Fixed long-time broken encryption via xbcrypt in combination with
mariabackup and added support for key-based encryption via openssl
utility, which is now enabled by default for encrypt=1 mode (this
default mode can be changed using a new configuration file option
"encypt-format=openssl|xbcrypt", which can be placed in the [mysqld],
[sst] or in the [xtrabackup] section) - this change will allow us
to use and to test the encypt=1 encryption without installing
non-standard third-party utilities.
2021-05-10 04:27:16 +02:00
. $( dirname " $0 " ) /wsrep_sst_common
2014-08-06 15:39:15 +03:00
2024-09-15 04:34:33 +02:00
CLIENT_DIR = " $SCRIPTS_DIR /../client "
2024-09-16 16:39:59 +02:00
if [ -x " $CLIENT_DIR /mariadb " ] ; then
MYSQL_CLIENT = " $CLIENT_DIR /mariadb "
2024-09-15 04:34:33 +02:00
else
2024-09-16 16:39:59 +02:00
MYSQL_CLIENT = $( commandex 'mariadb' )
2024-09-15 04:34:33 +02:00
fi
2024-09-16 16:39:59 +02:00
if [ -x " $CLIENT_DIR /mariadb-dump " ] ; then
MYSQLDUMP = " $CLIENT_DIR /mariadb-dump "
2024-09-15 04:34:33 +02:00
else
2024-09-16 16:39:59 +02:00
MYSQLDUMP = $( commandex 'mariadb-dump' )
2024-09-15 04:34:33 +02:00
fi
2024-09-15 04:12:27 +02:00
wait_previous_sst
2014-08-06 15:39:15 +03:00
EINVAL = 22
if test -z " $WSREP_SST_OPT_HOST " ; then wsrep_log_error "HOST cannot be nil" ; exit $EINVAL ; fi
if test -z " $WSREP_SST_OPT_PORT " ; then wsrep_log_error "PORT cannot be nil" ; exit $EINVAL ; fi
if test -z " $WSREP_SST_OPT_LPORT " ; then wsrep_log_error "LPORT cannot be nil" ; exit $EINVAL ; fi
if test -z " $WSREP_SST_OPT_SOCKET " ; then wsrep_log_error "SOCKET cannot be nil" ; exit $EINVAL ; fi
if test -z " $WSREP_SST_OPT_GTID " ; then wsrep_log_error "GTID cannot be nil" ; exit $EINVAL ; fi
MDEV-23580: WSREP_SST: [ERROR] rsync daemon port has been taken
This commit contains a large set of further bug fixes and
improvements to SST scripts for Galera, continuing the work
that was started in MDEV-24962 to make SST scripts work smoothly
in different network configurations (especially using ipv6) and
with different environment settings:
1) The ipv6 addresses were incorrectly handled in the SST script
for rsync (incorrect address substitution for establishing a
connection, incorrect address substitution for bind, and so on);
2) Checking the locality of the ip-address in SST scripts did not
support ipv6 addresses (such as "[::1]"), which were falsely
identified as non-local ip, which further did not allow running
two SSTs on different local addresses on the same machine.
On the other hand, this bug masked some other errors (related
to handling ipv6 addresses);
3) The code for checking the locality of the ip address was different
in the SST scripts for rsync and for mysqldump, with individual
flaws. This code is now made common and moved to wsrep_sst_common;
4) Waiting for the start of the transport channel (socat, nc, rsync,
stunnel) in the wait_for_listen() and check_pid_and_port() functions
did not process ipv6 addresses correctly in all cases (not for all
branches);
5) Waiting for the start of the transport channel (socat, nc, rsync,
stunnel) in the wait_for_listen() and check_pid_and_port() functions
for some code branches could give a false positive result due to
the textual match of prefixes in the port number and/or PID of
the process;
6) Waiting for the start of the transport channel (socat, nc, rsync,
stunnel) was supported through different utilities in SST scripts
for mariabackup and for rsync, and with various minor flaws in
the code. Now the code is still different in these scripts, but
it supports a common set of utilities (lsof, ss, sockstat) and
is synchronized across patterns that used to check the output
of these utilities;
7) In SST via mariabackup, the signal about readiness to receive data
is sometimes sent too early - immediately after listen(), and not
after accept() (which are called by socat or netcat utility).
8) Checking availability of the some options of some utilities was
done using the grep pattern, which easily gives false positives;
9) Common name (CN) for local addresses, if not explicitly specified,
is now always replaced to "localhost" to avoid the need to generate
many separate certificates for local addresses of one machine and
not to depend on which the local address is currently used in test
(ipv4 or ipv6, etc.);
10) In tests galera_sst_mariabackup_encrypt_with_key_server and
galera_sst_rsync_encrypt_with_key_server the correct certificate
is selected to avoid commonname (CN) mismatch problems;
11) Further refactoring to protect against spaces in file names.
12) Further general refactoring to eliminate bash-specific constructs
or to improve code readability;
13) The code for setting options for the nc (netcat) utility was
different in different scripts for SST - now it is made identical.
14) Fixed long-time broken encryption via xbcrypt in combination with
mariabackup and added support for key-based encryption via openssl
utility, which is now enabled by default for encrypt=1 mode (this
default mode can be changed using a new configuration file option
"encypt-format=openssl|xbcrypt", which can be placed in the [mysqld],
[sst] or in the [xtrabackup] section) - this change will allow us
to use and to test the encypt=1 encryption without installing
non-standard third-party utilities.
2021-05-10 04:27:16 +02:00
if is_local_ip " $WSREP_SST_OPT_HOST_UNESCAPED " && \
2014-08-06 15:39:15 +03:00
[ " $WSREP_SST_OPT_PORT " = " $WSREP_SST_OPT_LPORT " ]
then
wsrep_log_error \
2024-09-15 04:34:33 +02:00
" destination address ' $WSREP_SST_OPT_HOST : $WSREP_SST_OPT_PORT ' " \
"matches source address."
2014-08-06 15:39:15 +03:00
exit $EINVAL
fi
# Check client version
2022-12-11 00:23:16 +01:00
if ! $MYSQL_CLIENT --version | grep -q -E '(Distrib 10\.[1-9])|( from 1[1-9]\.)' ; then
2015-07-14 16:05:29 -04:00
$MYSQL_CLIENT --version >& 2
2018-01-14 18:57:48 +11:00
wsrep_log_error "this operation requires MySQL client version 10.1 or newer"
2014-08-06 15:39:15 +03:00
exit $EINVAL
fi
2021-05-21 03:11:48 +02:00
AUTH = ""
if [ -n " $WSREP_SST_OPT_USER " ] ; then
AUTH = " -u $WSREP_SST_OPT_USER "
2024-06-11 02:11:02 +02:00
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 "
2021-05-21 03:11:48 +02:00
fi
2015-06-06 01:08:41 +03:00
# Refs https://github.com/codership/mysql-wsrep/issues/141
# Passing password in MYSQL_PWD environment variable is considered
# "extremely insecure" by MySQL Guidelines for Password Security
# (https://dev.mysql.com/doc/refman/5.6/en/password-security-user.html)
# that is even less secure than passing it on a command line! It is doubtful:
2015-06-06 01:08:41 +03:00
# the whole command line is easily observable by any unprivileged user via ps,
# whereas (at least on Linux) unprivileged user can't see process environment
# that he does not own. So while it may be not secure in the NSA sense of the
# word, it is arguably more secure than passing password on the command line.
2023-07-26 22:34:56 +03:00
if [ -n " $WSREP_SST_OPT_REMOTE_PSWD " ] ; then
export MYSQL_PWD = " $WSREP_SST_OPT_REMOTE_PSWD "
2024-06-11 02:11:02 +02:00
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
2021-05-21 03:11:48 +02:00
# Empty password, used for testing, debugging etc.
unset MYSQL_PWD
fi
2014-08-06 15:39:15 +03:00
2021-05-21 03:11:48 +02:00
STOP_WSREP = 'SET wsrep_on=OFF;'
2014-08-06 15:39:15 +03:00
# mysqldump cannot restore CSV tables, fix this issue
CSV_TABLES_FIX = "
set sql_mode = '' ;
USE mysql;
SET @cond = ( SELECT ( SUPPORT = 'YES' or SUPPORT = 'DEFAULT' ) FROM INFORMATION_SCHEMA.ENGINES WHERE ENGINE = 'csv' ) ;
2021-05-21 03:11:48 +02:00
SET @stmt = IF ( @cond = '1' , 'CREATE TABLE IF NOT EXISTS general_log ( event_time timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), user_host mediumtext NOT NULL, thread_id bigint(21) unsigned NOT NULL, server_id int(10) unsigned NOT NULL, command_type varchar(64) NOT NULL, argument mediumtext NOT NULL) ENGINE=CSV DEFAULT CHARSET=utf8mb3 COMMENT=\"General log\"' , 'SET @dummy = 0' ) ;
2014-08-06 15:39:15 +03:00
PREPARE stmt FROM @stmt;
EXECUTE stmt;
DROP PREPARE stmt;
2023-07-13 13:39:54 +02:00
SET @stmt = IF ( @cond = '1' , 'CREATE TABLE IF NOT EXISTS slow_log ( start_time timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), user_host mediumtext NOT NULL, query_time time(6) NOT NULL, lock_time time(6) NOT NULL, rows_sent bigint(20) UNSIGNED NOT NULL, rows_examined bigint(20) UNSIGNED NOT NULL, db varchar(512) NOT NULL, last_insert_id int(11) NOT NULL, insert_id int(11) NOT NULL, server_id int(10) unsigned NOT NULL, sql_text mediumtext NOT NULL, thread_id bigint(21) unsigned NOT NULL) ENGINE=CSV DEFAULT CHARSET=utf8mb3 COMMENT=\"Slow log\"' , 'SET @dummy = 0' ) ;
2014-08-06 15:39:15 +03:00
PREPARE stmt FROM @stmt;
EXECUTE stmt;
DROP PREPARE stmt; "
2023-07-26 22:34:56 +03:00
STATE = " $WSREP_SST_OPT_GTID $WSREP_SST_OPT_GTID_DOMAIN_ID "
2014-08-06 15:39:15 +03:00
SET_START_POSITION = " SET GLOBAL wsrep_start_position=' $WSREP_SST_OPT_GTID '; "
2015-02-27 22:33:41 -05:00
SET_WSREP_GTID_DOMAIN_ID = ""
MDEV-27524: Incorrect binlogs after Galera SST using rsync and mariabackup
This commit adds correct handling of binlogs for SST using rsync
or mariabackup. Before this fix, binlogs were handled incorrectly -
- only one (last) binary log file was transferred during SST, which
then led to various failures (for example, when trying to list all
events from the binary log). These bugs were long masked by flaws
in the primitive binlogs handling code in the SST scripts, which
causing binary logs files to be erased after transfer or not added
to the binlog index on the joiner node. Now the correct transfer
of all binary logs (not just the last of the binary log files) has
been implemented both for the rsync (at the script level) and for
the mariabackup (at the level of the main utility code).
This commit also adds a new sst_max_binlogs=<n> parameter, which
can be located in the [sst] section or in the [xtrabackup] section
(historically, supported for mariabackup only, not for rsync), or
in one of the server sections. This parameter specifies the number
of binary log files to be sent to the joiner node during SST. This
option is added for compatibility with old SST scripting behavior,
which can be emulated by setting the sst_max_binlogs=1 (although
in general this can cause problems for the reasons described above).
In addition, setting the sst_max_binlogs=0 can be used to suppress
the transmission of binary logs to the joiner nodes during SST
(although sometimes a single file with the current binary log can
still be transmitted to the joiner, even with sst_max_binlogs=0,
because this sometimes necessary in modes that involve the use of
GTIDs with Galera).
Also, this commit ensures correct handling of paths to various
innodb files and directories in the SST scripts, and fixes some
problems with this that existed in mariabackup utility (which
were associated with incorrect handling of the innodb_data_dir
parameter in some scenarios).
In addition, this commit contains the following enhancements:
1) Added tests for mtr, which check the correct work with binlogs
after SST (using rsync and mariabackup);
2) Added correct handling of slashes at the end of all paths that
the SST script receives as parameters;
3) Improved parsing code for --mysqld-args parameters. Now it
correctly processes the sequence "--" after the name of the
one-letter option;
4) Checking the secret signature during joiner authentication
is made independent of presence of bash (as a unix shell)
in the system and diff utility no longer needed to check
certificates compliance;
5) All directories that are necessary for the correct placement
of various logs are automatically created by SST scripts in
advance (before running mariabackup on the joiner node);
6) Removal of old binary logs on joiner is done using the binlog
index (if it exists) (not only by fixed pattern that based
on the current binlog name, as before);
7) Paths for placing binary logs are correctly processed if they
are set as relative paths (to the datadir);
8) SST scripts are made even more resistant to spaces in filenames
(now for binlogs);
9) In case of failure, SST scripts now always end with an exit
code other than zero;
10) SST script for rsync now correctly create a tar file with
the binlogs, even if the paths to them (in the binlog index
file) are specified as a mix of absolute and relative paths,
and even if they do not match with the datadir path specified
in the current configuration settings.
2022-02-22 10:45:06 +01:00
if [ -n " $WSREP_SST_OPT_GTID_DOMAIN_ID " ] ; then
2021-04-15 13:53:28 +02:00
SET_WSREP_GTID_DOMAIN_ID = "
SET @val = ( SELECT GLOBAL_VALUE FROM INFORMATION_SCHEMA.SYSTEM_VARIABLES WHERE VARIABLE_NAME = 'WSREP_GTID_STRICT_MODE' AND GLOBAL_VALUE > 0) ;
SET @stmt = IF ( @val IS NOT NULL, 'SET GLOBAL WSREP_GTID_DOMAIN_ID=$WSREP_SST_OPT_GTID_DOMAIN_ID' , 'SET @dummy = 0' ) ;
PREPARE stmt FROM @stmt;
EXECUTE stmt;
DROP PREPARE stmt; "
2015-02-27 22:33:41 -05:00
fi
2021-12-13 02:15:57 +01:00
MYSQL = " $MYSQL_CLIENT $WSREP_SST_OPT_CONF_UNQUOTED " \
2023-07-26 22:34:56 +03:00
" $REMOTE_AUTH -h $WSREP_SST_OPT_HOST_UNESCAPED " \
2017-03-03 20:28:27 +00:00
" -P $WSREP_SST_OPT_PORT --disable-reconnect --connect_timeout=10 "
2014-08-06 15:39:15 +03:00
2015-02-27 22:30:38 -05:00
# Check if binary logging is enabled on the joiner node.
# Note: SELECT cannot be used at this point.
2021-05-21 03:11:48 +02:00
LOG_BIN = $( echo "set statement wsrep_sync_wait=0 for SHOW VARIABLES LIKE 'log_bin'" | $MYSQL | \
2015-02-27 22:30:38 -05:00
tail -1 | awk -F ' ' '{ print $2 }' )
# Check the joiner node's server version.
2021-05-21 03:11:48 +02:00
SERVER_VERSION = $( echo "set statement wsrep_sync_wait=0 for SHOW VARIABLES LIKE 'version'" | $MYSQL | \
2015-02-27 22:30:38 -05:00
tail -1 | awk -F ' ' '{ print $2 }' )
2018-06-15 18:20:36 +02:00
# Retrieve the donor's @@global.gtid_binlog_state.
2021-05-21 03:11:48 +02:00
GTID_BINLOG_STATE = $( echo "SHOW GLOBAL VARIABLES LIKE 'gtid_binlog_state'" | $MYSQL | \
2018-06-15 18:20:36 +02:00
tail -1 | awk -F ' ' '{ print $2 }' )
2015-02-27 22:30:38 -05:00
RESET_MASTER = ""
SET_GTID_BINLOG_STATE = ""
SQL_LOG_BIN_OFF = ""
# Safety check
2021-12-13 02:15:57 +01:00
if [ ${ SERVER_VERSION %%.* } -gt 5 ] ; then
2021-04-15 13:53:28 +02:00
# If binary logging is enabled on the joiner node, we need to copy donor's
# gtid_binlog_state to joiner. In order to do that, a RESET MASTER must be
# executed to erase binary logs (if any). Binary logging should also be
# turned off for the session so that gtid state does not get altered while
# the dump gets replayed on joiner.
MDEV-23580: WSREP_SST: [ERROR] rsync daemon port has been taken
This commit contains a large set of further bug fixes and
improvements to SST scripts for Galera, continuing the work
that was started in MDEV-24962 to make SST scripts work smoothly
in different network configurations (especially using ipv6) and
with different environment settings:
1) The ipv6 addresses were incorrectly handled in the SST script
for rsync (incorrect address substitution for establishing a
connection, incorrect address substitution for bind, and so on);
2) Checking the locality of the ip-address in SST scripts did not
support ipv6 addresses (such as "[::1]"), which were falsely
identified as non-local ip, which further did not allow running
two SSTs on different local addresses on the same machine.
On the other hand, this bug masked some other errors (related
to handling ipv6 addresses);
3) The code for checking the locality of the ip address was different
in the SST scripts for rsync and for mysqldump, with individual
flaws. This code is now made common and moved to wsrep_sst_common;
4) Waiting for the start of the transport channel (socat, nc, rsync,
stunnel) in the wait_for_listen() and check_pid_and_port() functions
did not process ipv6 addresses correctly in all cases (not for all
branches);
5) Waiting for the start of the transport channel (socat, nc, rsync,
stunnel) in the wait_for_listen() and check_pid_and_port() functions
for some code branches could give a false positive result due to
the textual match of prefixes in the port number and/or PID of
the process;
6) Waiting for the start of the transport channel (socat, nc, rsync,
stunnel) was supported through different utilities in SST scripts
for mariabackup and for rsync, and with various minor flaws in
the code. Now the code is still different in these scripts, but
it supports a common set of utilities (lsof, ss, sockstat) and
is synchronized across patterns that used to check the output
of these utilities;
7) In SST via mariabackup, the signal about readiness to receive data
is sometimes sent too early - immediately after listen(), and not
after accept() (which are called by socat or netcat utility).
8) Checking availability of the some options of some utilities was
done using the grep pattern, which easily gives false positives;
9) Common name (CN) for local addresses, if not explicitly specified,
is now always replaced to "localhost" to avoid the need to generate
many separate certificates for local addresses of one machine and
not to depend on which the local address is currently used in test
(ipv4 or ipv6, etc.);
10) In tests galera_sst_mariabackup_encrypt_with_key_server and
galera_sst_rsync_encrypt_with_key_server the correct certificate
is selected to avoid commonname (CN) mismatch problems;
11) Further refactoring to protect against spaces in file names.
12) Further general refactoring to eliminate bash-specific constructs
or to improve code readability;
13) The code for setting options for the nc (netcat) utility was
different in different scripts for SST - now it is made identical.
14) Fixed long-time broken encryption via xbcrypt in combination with
mariabackup and added support for key-based encryption via openssl
utility, which is now enabled by default for encrypt=1 mode (this
default mode can be changed using a new configuration file option
"encypt-format=openssl|xbcrypt", which can be placed in the [mysqld],
[sst] or in the [xtrabackup] section) - this change will allow us
to use and to test the encypt=1 encryption without installing
non-standard third-party utilities.
2021-05-10 04:27:16 +02:00
if [ " $LOG_BIN " = 'ON' ] ; then
MDEV-24962: Galera SST innobackupex-move ignores Environment settings
After switching to the new mariabackup interface (instead of
the outdated innobackupex interface, which is supported for
compatibility), we need to explicitly pass a path to the datadir
directory as a parameter, since in the new interface the value
of this option is not automatically set in such a way that it
always matches the SST/IST logic. This commit adds passing this
option as an explicit parameter to mariabackup. This commit also
removed unnecessary options that are not used and not supported
by mariabackup.
Also, numerous flaws in the common wsrep_sst_common script have
been fixed:
1) There are many bash-specific constructs in the script that
may not be supported by other interpreters, which can lead
to the most unexpected errors during SST, because failures
in the interpretation of bash-specific constructs lead to
incorrect parsing of arguments;
2) There is parse_cnf() function which is often called by other
scripts for the "mysqld" or "--mysqld" group, but it does not
take into account the default group suffix, which leads to
reading values only from the default group, which then leads
to errors due to reading the default values instead of the
values for a specific group;
3) Some options such as --user, --innodb-data-home-dir or --datadir
are not removed from the --mysqld-args list, although they are
processed inside scripts (and passing of these options funther
may cause problems for mariabackup);
4) If an argument that the script understands is present in
the --mysqld-args list twice, then this causes SST to fail,
instead of reading the most recent value;
5) The "--host" parameter is technically still supported among
the arguments of the SST scripts, but in reality scripts do not
work with it as expected, especially if it has an IPv6 address;
6) If the port number is absent in the --address parameter value,
but the port number is explicitly passed through the --port
argument, then the scripts for mariabackup and xtrabackup-v2
fail;
7) If a new address interface is used (with the --address parameter),
then automatic default port substitution is not performed, although
it is supported for the legacy --host/--port interface.
8) If there are spaces in the parameter values after --mysqld_args,
then their further transfer does not occur correctly, which
causes mariabackup to fail during SST - the space splits
the argument in such a way that it breaks the parsing of the
following parameters;
9) If most of the parameters that are names or paths to the files
or directories contain spaces, then SST scripts fail in an
unpredictable way due to incorrect variable substitutions;
10) If the --log-bin option is passed among the arguments of myqlds
(--mysqld-args) without a parameter, and the --binlog option
is not specified, then the script cannot substitute the default
name for binlog and cannot construct binlog name using the
--log-basename argument (which is against server specifications);
11) Tail slashes are not removed from the directory names, which,
upon further substitution, leads to the appearance of a double
slash in the file paths;
12) The explicit --binlog parameter (which is now always transmitted
from the server side) and the "hidden" --log-bin parameter in the
list of arguments after --mysqld-args are perceived as two different
parameters in different parts of the scripts, and if they are do not
match for some reason, this will lead to failures during SST;
Also, all new changes from the 10.6 branch have been migrated here,
including the latest pull requests for authentication (only the part
that concerns SST scripts).
It also fixes dozens of other bugs in all SST scripts.
2021-04-28 01:39:31 +02:00
RESET_MASTER = "SET GLOBAL wsrep_on=OFF; RESET MASTER; SET GLOBAL wsrep_on=ON;"
SET_GTID_BINLOG_STATE = " SET GLOBAL wsrep_on=OFF; SET @@global.gtid_binlog_state=' $GTID_BINLOG_STATE '; SET GLOBAL wsrep_on=ON; "
2021-04-15 13:53:28 +02:00
SQL_LOG_BIN_OFF = "SET @@session.sql_log_bin=OFF;"
fi
2015-02-27 22:30:38 -05:00
fi
# NOTE: we don't use --routines here because we're dumping mysql.proc table
2021-12-13 02:15:57 +01:00
MYSQLDUMP = " $MYSQLDUMP $WSREP_SST_OPT_CONF_UNQUOTED $AUTH -S $WSREP_SST_OPT_SOCKET \
2015-02-27 22:30:38 -05:00
--add-drop-database --add-drop-table --skip-add-locks --create-options \
--disable-keys --extended-insert --skip-lock-tables --quick --set-charset \
2015-09-09 20:51:39 -04:00
--skip-comments --flush-privileges --all-databases --events"
2015-02-27 22:30:38 -05:00
2014-08-06 15:39:15 +03:00
if [ $WSREP_SST_OPT_BYPASS -eq 0 ]
then
2021-05-21 03:11:48 +02:00
# need to disable logging when loading the dump
# reason is that dump contains ALTER TABLE for log tables, and
# this causes an error if logging is enabled
GENERAL_LOG_OPT = $( $MYSQL --skip-column-names -e " $STOP_WSREP SELECT @@GENERAL_LOG " )
2022-09-26 19:21:24 +02:00
SLOW_LOG_OPT = $( $MYSQL --skip-column-names -e " $STOP_WSREP SELECT @@LOG_SLOW_QUERY " )
2021-05-21 03:11:48 +02:00
2022-09-26 19:21:24 +02:00
LOG_OFF = "SET GLOBAL GENERAL_LOG=OFF; SET GLOBAL LOG_SLOW_QUERY=OFF;"
2021-05-21 03:11:48 +02:00
# commands to restore log settings
RESTORE_GENERAL_LOG = " SET GLOBAL GENERAL_LOG= $GENERAL_LOG_OPT ; "
2022-09-26 19:21:24 +02:00
RESTORE_SLOW_QUERY_LOG = " SET GLOBAL LOG_SLOW_QUERY= $SLOW_LOG_OPT ; "
2021-05-21 03:11:48 +02:00
( echo " $STOP_WSREP " && echo " $LOG_OFF " && echo " $RESET_MASTER " && \
echo " $SET_GTID_BINLOG_STATE " && echo " $SQL_LOG_BIN_OFF " && \
echo " $STOP_WSREP " && $MYSQLDUMP && echo " $CSV_TABLES_FIX " && \
echo " $RESTORE_GENERAL_LOG " && echo " $RESTORE_SLOW_QUERY_LOG " && \
echo " $SET_START_POSITION " && echo " $SET_WSREP_GTID_DOMAIN_ID " \
2022-05-17 11:04:04 +02:00
|| echo "SST failed to complete;" ) | $MYSQL || exit $?
2014-08-06 15:39:15 +03:00
else
wsrep_log_info "Bypassing state dump."
2022-05-17 11:04:04 +02:00
echo " $SET_START_POSITION " | $MYSQL || exit $?
2014-08-06 15:39:15 +03:00
fi
2023-07-26 22:34:56 +03:00
echo " done $STATE "
2022-05-17 11:04:04 +02:00
wsrep_log_info " $WSREP_METHOD $WSREP_TRANSFER_TYPE completed on $WSREP_SST_OPT_ROLE "
exit 0