You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1223 lines
38 KiB

MDEV-21770: `galera_3nodes.galera_ipv6_mariabackup` fails This patch fixes several flaws in the SST scripts that cause failures while running tests that use version 6 IP addresses for cluster nodes. First, if the netcat utility is used for streaming (but not socat), then in accordance with its command line syntax, we need to remove the square brackets around the IPv6 address. However, for socat, the address must contain square brackets, as before. Secondly, if an IPv6 address is used, then from the joiner side for a number of systems (such as Debian) we need to explicitly specify the "-6" option, otherwise a listening socket with an IPv6 address may not be created. This patch also contains code improvements in the wsrep_sst_common. Changed the code that pars the connection address - fixed the shortcomings that sometimes led to incorrect parsing of parameters when using shells other than the latest versions of bash. Also, this patch removes the duplicate code that is intended for parsing the connection address and which was located in the wsrep_sst_mariabackup file, since all the necessary actions have already been done in wsrep_sst_common and there they are done in such a way that any shell is supported, not just bash. The fix does not require separate tests, since all the necessary tests are already present in the galera_3nodes suite. On the contrary, after this fix, tests using IPv6 addresses can be removed from the disabled list (this will be done in a separate commit related to MDEV-23659).
5 years ago
MDEV-21770: `galera_3nodes.galera_ipv6_mariabackup` fails This patch fixes several flaws in the SST scripts that cause failures while running tests that use version 6 IP addresses for cluster nodes. First, if the netcat utility is used for streaming (but not socat), then in accordance with its command line syntax, we need to remove the square brackets around the IPv6 address. However, for socat, the address must contain square brackets, as before. Secondly, if an IPv6 address is used, then from the joiner side for a number of systems (such as Debian) we need to explicitly specify the "-6" option, otherwise a listening socket with an IPv6 address may not be created. This patch also contains code improvements in the wsrep_sst_common. Changed the code that pars the connection address - fixed the shortcomings that sometimes led to incorrect parsing of parameters when using shells other than the latest versions of bash. Also, this patch removes the duplicate code that is intended for parsing the connection address and which was located in the wsrep_sst_mariabackup file, since all the necessary actions have already been done in wsrep_sst_common and there they are done in such a way that any shell is supported, not just bash. The fix does not require separate tests, since all the necessary tests are already present in the galera_3nodes suite. On the contrary, after this fix, tests using IPv6 addresses can be removed from the disabled list (this will be done in a separate commit related to MDEV-23659).
5 years ago
MDEV-21770: `galera_3nodes.galera_ipv6_mariabackup` fails This patch fixes several flaws in the SST scripts that cause failures while running tests that use version 6 IP addresses for cluster nodes. First, if the netcat utility is used for streaming (but not socat), then in accordance with its command line syntax, we need to remove the square brackets around the IPv6 address. However, for socat, the address must contain square brackets, as before. Secondly, if an IPv6 address is used, then from the joiner side for a number of systems (such as Debian) we need to explicitly specify the "-6" option, otherwise a listening socket with an IPv6 address may not be created. This patch also contains code improvements in the wsrep_sst_common. Changed the code that pars the connection address - fixed the shortcomings that sometimes led to incorrect parsing of parameters when using shells other than the latest versions of bash. Also, this patch removes the duplicate code that is intended for parsing the connection address and which was located in the wsrep_sst_mariabackup file, since all the necessary actions have already been done in wsrep_sst_common and there they are done in such a way that any shell is supported, not just bash. The fix does not require separate tests, since all the necessary tests are already present in the galera_3nodes suite. On the contrary, after this fix, tests using IPv6 addresses can be removed from the disabled list (this will be done in a separate commit related to MDEV-23659).
5 years ago
MDEV-21770: `galera_3nodes.galera_ipv6_mariabackup` fails This patch fixes several flaws in the SST scripts that cause failures while running tests that use version 6 IP addresses for cluster nodes. First, if the netcat utility is used for streaming (but not socat), then in accordance with its command line syntax, we need to remove the square brackets around the IPv6 address. However, for socat, the address must contain square brackets, as before. Secondly, if an IPv6 address is used, then from the joiner side for a number of systems (such as Debian) we need to explicitly specify the "-6" option, otherwise a listening socket with an IPv6 address may not be created. This patch also contains code improvements in the wsrep_sst_common. Changed the code that pars the connection address - fixed the shortcomings that sometimes led to incorrect parsing of parameters when using shells other than the latest versions of bash. Also, this patch removes the duplicate code that is intended for parsing the connection address and which was located in the wsrep_sst_mariabackup file, since all the necessary actions have already been done in wsrep_sst_common and there they are done in such a way that any shell is supported, not just bash. The fix does not require separate tests, since all the necessary tests are already present in the galera_3nodes suite. On the contrary, after this fix, tests using IPv6 addresses can be removed from the disabled list (this will be done in a separate commit related to MDEV-23659).
5 years ago
MDEV-21770: `galera_3nodes.galera_ipv6_mariabackup` fails This patch fixes several flaws in the SST scripts that cause failures while running tests that use version 6 IP addresses for cluster nodes. First, if the netcat utility is used for streaming (but not socat), then in accordance with its command line syntax, we need to remove the square brackets around the IPv6 address. However, for socat, the address must contain square brackets, as before. Secondly, if an IPv6 address is used, then from the joiner side for a number of systems (such as Debian) we need to explicitly specify the "-6" option, otherwise a listening socket with an IPv6 address may not be created. This patch also contains code improvements in the wsrep_sst_common. Changed the code that pars the connection address - fixed the shortcomings that sometimes led to incorrect parsing of parameters when using shells other than the latest versions of bash. Also, this patch removes the duplicate code that is intended for parsing the connection address and which was located in the wsrep_sst_mariabackup file, since all the necessary actions have already been done in wsrep_sst_common and there they are done in such a way that any shell is supported, not just bash. The fix does not require separate tests, since all the necessary tests are already present in the galera_3nodes suite. On the contrary, after this fix, tests using IPv6 addresses can be removed from the disabled list (this will be done in a separate commit related to MDEV-23659).
5 years ago
MDEV-21770: `galera_3nodes.galera_ipv6_mariabackup` fails This patch fixes several flaws in the SST scripts that cause failures while running tests that use version 6 IP addresses for cluster nodes. First, if the netcat utility is used for streaming (but not socat), then in accordance with its command line syntax, we need to remove the square brackets around the IPv6 address. However, for socat, the address must contain square brackets, as before. Secondly, if an IPv6 address is used, then from the joiner side for a number of systems (such as Debian) we need to explicitly specify the "-6" option, otherwise a listening socket with an IPv6 address may not be created. This patch also contains code improvements in the wsrep_sst_common. Changed the code that pars the connection address - fixed the shortcomings that sometimes led to incorrect parsing of parameters when using shells other than the latest versions of bash. Also, this patch removes the duplicate code that is intended for parsing the connection address and which was located in the wsrep_sst_mariabackup file, since all the necessary actions have already been done in wsrep_sst_common and there they are done in such a way that any shell is supported, not just bash. The fix does not require separate tests, since all the necessary tests are already present in the galera_3nodes suite. On the contrary, after this fix, tests using IPv6 addresses can be removed from the disabled list (this will be done in a separate commit related to MDEV-23659).
5 years ago
MDEV-21770: `galera_3nodes.galera_ipv6_mariabackup` fails This patch fixes several flaws in the SST scripts that cause failures while running tests that use version 6 IP addresses for cluster nodes. First, if the netcat utility is used for streaming (but not socat), then in accordance with its command line syntax, we need to remove the square brackets around the IPv6 address. However, for socat, the address must contain square brackets, as before. Secondly, if an IPv6 address is used, then from the joiner side for a number of systems (such as Debian) we need to explicitly specify the "-6" option, otherwise a listening socket with an IPv6 address may not be created. This patch also contains code improvements in the wsrep_sst_common. Changed the code that pars the connection address - fixed the shortcomings that sometimes led to incorrect parsing of parameters when using shells other than the latest versions of bash. Also, this patch removes the duplicate code that is intended for parsing the connection address and which was located in the wsrep_sst_mariabackup file, since all the necessary actions have already been done in wsrep_sst_common and there they are done in such a way that any shell is supported, not just bash. The fix does not require separate tests, since all the necessary tests are already present in the galera_3nodes suite. On the contrary, after this fix, tests using IPv6 addresses can be removed from the disabled list (this will be done in a separate commit related to MDEV-23659).
5 years ago
MDEV-21770: `galera_3nodes.galera_ipv6_mariabackup` fails This patch fixes several flaws in the SST scripts that cause failures while running tests that use version 6 IP addresses for cluster nodes. First, if the netcat utility is used for streaming (but not socat), then in accordance with its command line syntax, we need to remove the square brackets around the IPv6 address. However, for socat, the address must contain square brackets, as before. Secondly, if an IPv6 address is used, then from the joiner side for a number of systems (such as Debian) we need to explicitly specify the "-6" option, otherwise a listening socket with an IPv6 address may not be created. This patch also contains code improvements in the wsrep_sst_common. Changed the code that pars the connection address - fixed the shortcomings that sometimes led to incorrect parsing of parameters when using shells other than the latest versions of bash. Also, this patch removes the duplicate code that is intended for parsing the connection address and which was located in the wsrep_sst_mariabackup file, since all the necessary actions have already been done in wsrep_sst_common and there they are done in such a way that any shell is supported, not just bash. The fix does not require separate tests, since all the necessary tests are already present in the galera_3nodes suite. On the contrary, after this fix, tests using IPv6 addresses can be removed from the disabled list (this will be done in a separate commit related to MDEV-23659).
5 years ago
MDEV-18863: Galera SST scripts can't read [mysqldN] option groups Some users and some scripts (for example, mysqld_multi.sh) use special option groups with names like [mysqld1], [mysqld2], ..., [mysqldN]. But SST scripts can't currently fully support these option groups. The only option group-related value it gets from the server is --defaults-group-suffix, if that option was set for mysqld when the server was started. However, the SST scripts does not get told by the server to read these option groups, so this means that the SST script will fail to read options like innodb-data-home-dir when it is in a option group like [mysqld1]...[mysqldN]. Moreover, SST scripts ignore many parameters that can be passed to them explicitly and cannot transfer them further, for example, to the input of mariabackup utility. Ideally, we want to transfer all the parameters of the original mysqld call to utilities such as mariabackup, however the SST script does not receive these parameters from the server and therefore cannot transfer them to mariabackup. To correct these shortcomings, we need to transfer to the scripts all of the parameters of the original mysqld call, and in the SST scripts themselves provide for the transfer all of these parameters to utilities such as mariabackup. To prevent these parameters from mixing with the script's own parameters, they should be transferred to SST script after the special option "--mysqld-args", followed by the string argument with the original parameters, as it received by the mysqld call at the time of launch (further all these parameters will be passed to mariabackup, for example). In addition, the SST scripts themselves must be refined so that they can read the parameters from the user-selected group, not just from the global mysqld configuration group. And also so that they can receive the parameters (which important for their work) as command-line arguments.
6 years ago
MDEV-18863: Galera SST scripts can't read [mysqldN] option groups Some users and some scripts (for example, mysqld_multi.sh) use special option groups with names like [mysqld1], [mysqld2], ..., [mysqldN]. But SST scripts can't currently fully support these option groups. The only option group-related value it gets from the server is --defaults-group-suffix, if that option was set for mysqld when the server was started. However, the SST scripts does not get told by the server to read these option groups, so this means that the SST script will fail to read options like innodb-data-home-dir when it is in a option group like [mysqld1]...[mysqldN]. Moreover, SST scripts ignore many parameters that can be passed to them explicitly and cannot transfer them further, for example, to the input of mariabackup utility. Ideally, we want to transfer all the parameters of the original mysqld call to utilities such as mariabackup, however the SST script does not receive these parameters from the server and therefore cannot transfer them to mariabackup. To correct these shortcomings, we need to transfer to the scripts all of the parameters of the original mysqld call, and in the SST scripts themselves provide for the transfer all of these parameters to utilities such as mariabackup. To prevent these parameters from mixing with the script's own parameters, they should be transferred to SST script after the special option "--mysqld-args", followed by the string argument with the original parameters, as it received by the mysqld call at the time of launch (further all these parameters will be passed to mariabackup, for example). In addition, the SST scripts themselves must be refined so that they can read the parameters from the user-selected group, not just from the global mysqld configuration group. And also so that they can receive the parameters (which important for their work) as command-line arguments.
6 years ago
MDEV-18863: Galera SST scripts can't read [mysqldN] option groups Some users and some scripts (for example, mysqld_multi.sh) use special option groups with names like [mysqld1], [mysqld2], ..., [mysqldN]. But SST scripts can't currently fully support these option groups. The only option group-related value it gets from the server is --defaults-group-suffix, if that option was set for mysqld when the server was started. However, the SST scripts does not get told by the server to read these option groups, so this means that the SST script will fail to read options like innodb-data-home-dir when it is in a option group like [mysqld1]...[mysqldN]. Moreover, SST scripts ignore many parameters that can be passed to them explicitly and cannot transfer them further, for example, to the input of mariabackup utility. Ideally, we want to transfer all the parameters of the original mysqld call to utilities such as mariabackup, however the SST script does not receive these parameters from the server and therefore cannot transfer them to mariabackup. To correct these shortcomings, we need to transfer to the scripts all of the parameters of the original mysqld call, and in the SST scripts themselves provide for the transfer all of these parameters to utilities such as mariabackup. To prevent these parameters from mixing with the script's own parameters, they should be transferred to SST script after the special option "--mysqld-args", followed by the string argument with the original parameters, as it received by the mysqld call at the time of launch (further all these parameters will be passed to mariabackup, for example). In addition, the SST scripts themselves must be refined so that they can read the parameters from the user-selected group, not just from the global mysqld configuration group. And also so that they can receive the parameters (which important for their work) as command-line arguments.
6 years ago
MDEV-18863: Galera SST scripts can't read [mysqldN] option groups Some users and some scripts (for example, mysqld_multi.sh) use special option groups with names like [mysqld1], [mysqld2], ..., [mysqldN]. But SST scripts can't currently fully support these option groups. The only option group-related value it gets from the server is --defaults-group-suffix, if that option was set for mysqld when the server was started. However, the SST scripts does not get told by the server to read these option groups, so this means that the SST script will fail to read options like innodb-data-home-dir when it is in a option group like [mysqld1]...[mysqldN]. Moreover, SST scripts ignore many parameters that can be passed to them explicitly and cannot transfer them further, for example, to the input of mariabackup utility. Ideally, we want to transfer all the parameters of the original mysqld call to utilities such as mariabackup, however the SST script does not receive these parameters from the server and therefore cannot transfer them to mariabackup. To correct these shortcomings, we need to transfer to the scripts all of the parameters of the original mysqld call, and in the SST scripts themselves provide for the transfer all of these parameters to utilities such as mariabackup. To prevent these parameters from mixing with the script's own parameters, they should be transferred to SST script after the special option "--mysqld-args", followed by the string argument with the original parameters, as it received by the mysqld call at the time of launch (further all these parameters will be passed to mariabackup, for example). In addition, the SST scripts themselves must be refined so that they can read the parameters from the user-selected group, not just from the global mysqld configuration group. And also so that they can receive the parameters (which important for their work) as command-line arguments.
6 years ago
MDEV-18863: Galera SST scripts can't read [mysqldN] option groups Some users and some scripts (for example, mysqld_multi.sh) use special option groups with names like [mysqld1], [mysqld2], ..., [mysqldN]. But SST scripts can't currently fully support these option groups. The only option group-related value it gets from the server is --defaults-group-suffix, if that option was set for mysqld when the server was started. However, the SST scripts does not get told by the server to read these option groups, so this means that the SST script will fail to read options like innodb-data-home-dir when it is in a option group like [mysqld1]...[mysqldN]. Moreover, SST scripts ignore many parameters that can be passed to them explicitly and cannot transfer them further, for example, to the input of mariabackup utility. Ideally, we want to transfer all the parameters of the original mysqld call to utilities such as mariabackup, however the SST script does not receive these parameters from the server and therefore cannot transfer them to mariabackup. To correct these shortcomings, we need to transfer to the scripts all of the parameters of the original mysqld call, and in the SST scripts themselves provide for the transfer all of these parameters to utilities such as mariabackup. To prevent these parameters from mixing with the script's own parameters, they should be transferred to SST script after the special option "--mysqld-args", followed by the string argument with the original parameters, as it received by the mysqld call at the time of launch (further all these parameters will be passed to mariabackup, for example). In addition, the SST scripts themselves must be refined so that they can read the parameters from the user-selected group, not just from the global mysqld configuration group. And also so that they can receive the parameters (which important for their work) as command-line arguments.
6 years ago
MDEV-18863: Galera SST scripts can't read [mysqldN] option groups Some users and some scripts (for example, mysqld_multi.sh) use special option groups with names like [mysqld1], [mysqld2], ..., [mysqldN]. But SST scripts can't currently fully support these option groups. The only option group-related value it gets from the server is --defaults-group-suffix, if that option was set for mysqld when the server was started. However, the SST scripts does not get told by the server to read these option groups, so this means that the SST script will fail to read options like innodb-data-home-dir when it is in a option group like [mysqld1]...[mysqldN]. Moreover, SST scripts ignore many parameters that can be passed to them explicitly and cannot transfer them further, for example, to the input of mariabackup utility. Ideally, we want to transfer all the parameters of the original mysqld call to utilities such as mariabackup, however the SST script does not receive these parameters from the server and therefore cannot transfer them to mariabackup. To correct these shortcomings, we need to transfer to the scripts all of the parameters of the original mysqld call, and in the SST scripts themselves provide for the transfer all of these parameters to utilities such as mariabackup. To prevent these parameters from mixing with the script's own parameters, they should be transferred to SST script after the special option "--mysqld-args", followed by the string argument with the original parameters, as it received by the mysqld call at the time of launch (further all these parameters will be passed to mariabackup, for example). In addition, the SST scripts themselves must be refined so that they can read the parameters from the user-selected group, not just from the global mysqld configuration group. And also so that they can receive the parameters (which important for their work) as command-line arguments.
6 years ago
MDEV-18863: Galera SST scripts can't read [mysqldN] option groups Some users and some scripts (for example, mysqld_multi.sh) use special option groups with names like [mysqld1], [mysqld2], ..., [mysqldN]. But SST scripts can't currently fully support these option groups. The only option group-related value it gets from the server is --defaults-group-suffix, if that option was set for mysqld when the server was started. However, the SST scripts does not get told by the server to read these option groups, so this means that the SST script will fail to read options like innodb-data-home-dir when it is in a option group like [mysqld1]...[mysqldN]. Moreover, SST scripts ignore many parameters that can be passed to them explicitly and cannot transfer them further, for example, to the input of mariabackup utility. Ideally, we want to transfer all the parameters of the original mysqld call to utilities such as mariabackup, however the SST script does not receive these parameters from the server and therefore cannot transfer them to mariabackup. To correct these shortcomings, we need to transfer to the scripts all of the parameters of the original mysqld call, and in the SST scripts themselves provide for the transfer all of these parameters to utilities such as mariabackup. To prevent these parameters from mixing with the script's own parameters, they should be transferred to SST script after the special option "--mysqld-args", followed by the string argument with the original parameters, as it received by the mysqld call at the time of launch (further all these parameters will be passed to mariabackup, for example). In addition, the SST scripts themselves must be refined so that they can read the parameters from the user-selected group, not just from the global mysqld configuration group. And also so that they can receive the parameters (which important for their work) as command-line arguments.
6 years ago
MDEV-18863: Galera SST scripts can't read [mysqldN] option groups Some users and some scripts (for example, mysqld_multi.sh) use special option groups with names like [mysqld1], [mysqld2], ..., [mysqldN]. But SST scripts can't currently fully support these option groups. The only option group-related value it gets from the server is --defaults-group-suffix, if that option was set for mysqld when the server was started. However, the SST scripts does not get told by the server to read these option groups, so this means that the SST script will fail to read options like innodb-data-home-dir when it is in a option group like [mysqld1]...[mysqldN]. Moreover, SST scripts ignore many parameters that can be passed to them explicitly and cannot transfer them further, for example, to the input of mariabackup utility. Ideally, we want to transfer all the parameters of the original mysqld call to utilities such as mariabackup, however the SST script does not receive these parameters from the server and therefore cannot transfer them to mariabackup. To correct these shortcomings, we need to transfer to the scripts all of the parameters of the original mysqld call, and in the SST scripts themselves provide for the transfer all of these parameters to utilities such as mariabackup. To prevent these parameters from mixing with the script's own parameters, they should be transferred to SST script after the special option "--mysqld-args", followed by the string argument with the original parameters, as it received by the mysqld call at the time of launch (further all these parameters will be passed to mariabackup, for example). In addition, the SST scripts themselves must be refined so that they can read the parameters from the user-selected group, not just from the global mysqld configuration group. And also so that they can receive the parameters (which important for their work) as command-line arguments.
6 years ago
MDEV-12548 Initial implementation of Mariabackup for MariaDB 10.2 InnoDB I/O and buffer pool interfaces and the redo log format have been changed between MariaDB 10.1 and 10.2, and the backup code has to be adjusted accordingly. The code has been simplified, and many memory leaks have been fixed. Instead of the file name xtrabackup_logfile, the file name ib_logfile0 is being used for the copy of the redo log. Unnecessary InnoDB startup and shutdown and some unnecessary threads have been removed. Some help was provided by Vladislav Vaintroub. Parameters have been cleaned up and aligned with those of MariaDB 10.2. The --dbug option has been added, so that in debug builds, --dbug=d,ib_log can be specified to enable diagnostic messages for processing redo log entries. By default, innodb_doublewrite=OFF, so that --prepare works faster. If more crash-safety for --prepare is needed, double buffering can be enabled. The parameter innodb_log_checksums=OFF can be used to ignore redo log checksums in --backup. Some messages have been cleaned up. Unless --export is specified, Mariabackup will not deal with undo log. The InnoDB mini-transaction redo log is not only about user-level transactions; it is actually about mini-transactions. To avoid confusion, call it the redo log, not transaction log. We disable any undo log processing in --prepare. Because MariaDB 10.2 supports indexed virtual columns, the undo log processing would need to be able to evaluate virtual column expressions. To reduce the amount of code dependencies, we will not process any undo log in prepare. This means that the --export option must be disabled for now. This also means that the following options are redundant and have been removed: xtrabackup --apply-log-only innobackupex --redo-only In addition to disabling any undo log processing, we will disable any further changes to data pages during --prepare, including the change buffer merge. This means that restoring incremental backups should reliably work even when change buffering is being used on the server. Because of this, preparing a backup will not generate any further redo log, and the redo log file can be safely deleted. (If the --export option is enabled in the future, it must generate redo log when processing undo logs and buffered changes.) In --prepare, we cannot easily know if a partial backup was used, especially when restoring a series of incremental backups. So, we simply warn about any missing files, and ignore the redo log for them. FIXME: Enable the --export option. FIXME: Improve the handling of the MLOG_INDEX_LOAD record, and write a test that initiates a backup while an ALGORITHM=INPLACE operation is creating indexes or rebuilding a table. An error should be detected when preparing the backup. FIXME: In --incremental --prepare, xtrabackup_apply_delta() should ensure that if FSP_SIZE is modified, the file size will be adjusted accordingly.
8 years ago
MDEV-18863: Galera SST scripts can't read [mysqldN] option groups Some users and some scripts (for example, mysqld_multi.sh) use special option groups with names like [mysqld1], [mysqld2], ..., [mysqldN]. But SST scripts can't currently fully support these option groups. The only option group-related value it gets from the server is --defaults-group-suffix, if that option was set for mysqld when the server was started. However, the SST scripts does not get told by the server to read these option groups, so this means that the SST script will fail to read options like innodb-data-home-dir when it is in a option group like [mysqld1]...[mysqldN]. Moreover, SST scripts ignore many parameters that can be passed to them explicitly and cannot transfer them further, for example, to the input of mariabackup utility. Ideally, we want to transfer all the parameters of the original mysqld call to utilities such as mariabackup, however the SST script does not receive these parameters from the server and therefore cannot transfer them to mariabackup. To correct these shortcomings, we need to transfer to the scripts all of the parameters of the original mysqld call, and in the SST scripts themselves provide for the transfer all of these parameters to utilities such as mariabackup. To prevent these parameters from mixing with the script's own parameters, they should be transferred to SST script after the special option "--mysqld-args", followed by the string argument with the original parameters, as it received by the mysqld call at the time of launch (further all these parameters will be passed to mariabackup, for example). In addition, the SST scripts themselves must be refined so that they can read the parameters from the user-selected group, not just from the global mysqld configuration group. And also so that they can receive the parameters (which important for their work) as command-line arguments.
6 years ago
MDEV-18863: Galera SST scripts can't read [mysqldN] option groups Some users and some scripts (for example, mysqld_multi.sh) use special option groups with names like [mysqld1], [mysqld2], ..., [mysqldN]. But SST scripts can't currently fully support these option groups. The only option group-related value it gets from the server is --defaults-group-suffix, if that option was set for mysqld when the server was started. However, the SST scripts does not get told by the server to read these option groups, so this means that the SST script will fail to read options like innodb-data-home-dir when it is in a option group like [mysqld1]...[mysqldN]. Moreover, SST scripts ignore many parameters that can be passed to them explicitly and cannot transfer them further, for example, to the input of mariabackup utility. Ideally, we want to transfer all the parameters of the original mysqld call to utilities such as mariabackup, however the SST script does not receive these parameters from the server and therefore cannot transfer them to mariabackup. To correct these shortcomings, we need to transfer to the scripts all of the parameters of the original mysqld call, and in the SST scripts themselves provide for the transfer all of these parameters to utilities such as mariabackup. To prevent these parameters from mixing with the script's own parameters, they should be transferred to SST script after the special option "--mysqld-args", followed by the string argument with the original parameters, as it received by the mysqld call at the time of launch (further all these parameters will be passed to mariabackup, for example). In addition, the SST scripts themselves must be refined so that they can read the parameters from the user-selected group, not just from the global mysqld configuration group. And also so that they can receive the parameters (which important for their work) as command-line arguments.
6 years ago
  1. #!/bin/bash -ue
  2. # Copyright (C) 2013 Percona Inc
  3. # Copyright (C) 2017-2020 MariaDB
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; version 2 of the License.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; see the file COPYING. If not, write to the
  16. # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston
  17. # MA 02110-1335 USA.
  18. # Documentation:
  19. # http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html
  20. # Make sure to read that before proceeding!
  21. . $(dirname $0)/wsrep_sst_common
  22. OS=$(uname)
  23. ealgo=""
  24. ekey=""
  25. ekeyfile=""
  26. encrypt=0
  27. nproc=1
  28. ecode=0
  29. ssyslog=""
  30. ssystag=""
  31. XTRABACKUP_PID=""
  32. SST_PORT=""
  33. REMOTEIP=""
  34. tcert=""
  35. tpem=""
  36. tkey=""
  37. sockopt=""
  38. progress=""
  39. ttime=0
  40. totime=0
  41. lsn=""
  42. ecmd=""
  43. rlimit=""
  44. # Initially
  45. stagemsg="${WSREP_SST_OPT_ROLE}"
  46. cpat=""
  47. speciald=1
  48. ib_home_dir=""
  49. ib_log_dir=""
  50. ib_undo_dir=""
  51. sfmt="tar"
  52. strmcmd=""
  53. tfmt=""
  54. tcmd=""
  55. rebuild=0
  56. rebuildcmd=""
  57. payload=0
  58. pvformat="-F '%N => Rate:%r Avg:%a Elapsed:%t %e Bytes: %b %p' "
  59. pvopts="-f -i 10 -N $WSREP_SST_OPT_ROLE "
  60. STATDIR=""
  61. uextra=0
  62. disver=""
  63. tmpopts=""
  64. itmpdir=""
  65. xtmpdir=""
  66. scomp=""
  67. sdecomp=""
  68. # Required for backup locks
  69. # For backup locks it is 1 sent by joiner
  70. # 5.6.21 PXC and later can't donate to an older joiner
  71. sst_ver=1
  72. if pv --help 2>/dev/null | grep -q FORMAT;then
  73. pvopts+=$pvformat
  74. fi
  75. pcmd="pv $pvopts"
  76. declare -a RC
  77. set +e
  78. INNOBACKUPEX_BIN=$(which mariabackup)
  79. if test -z $INNOBACKUPEX_BIN
  80. then
  81. wsrep_log_error 'mariabackup binary not found in $PATH'
  82. exit 42
  83. fi
  84. set -e
  85. XBSTREAM_BIN=mbstream
  86. XBCRYPT_BIN=xbcrypt # Not available in MariaBackup
  87. DATA="${WSREP_SST_OPT_DATA}"
  88. INFO_FILE="xtrabackup_galera_info"
  89. IST_FILE="xtrabackup_ist"
  90. MAGIC_FILE="${DATA}/${INFO_FILE}"
  91. INNOAPPLYLOG="${DATA}/mariabackup.prepare.log"
  92. INNOMOVELOG="${DATA}/mariabackup.move.log"
  93. INNOBACKUPLOG="${DATA}/mariabackup.backup.log"
  94. # Setting the path for ss and ip
  95. export PATH="/usr/sbin:/sbin:$PATH"
  96. timeit(){
  97. local stage=$1
  98. shift
  99. local cmd="$@"
  100. local x1 x2 took extcode
  101. if [[ $ttime -eq 1 ]];then
  102. x1=$(date +%s)
  103. wsrep_log_info "Evaluating $cmd"
  104. eval "$cmd"
  105. extcode=$?
  106. x2=$(date +%s)
  107. took=$(( x2-x1 ))
  108. wsrep_log_info "NOTE: $stage took $took seconds"
  109. totime=$(( totime+took ))
  110. else
  111. wsrep_log_info "Evaluating $cmd"
  112. eval "$cmd"
  113. extcode=$?
  114. fi
  115. return $extcode
  116. }
  117. get_keys()
  118. {
  119. # $encrypt -eq 1 is for internal purposes only
  120. if [[ $encrypt -ge 2 || $encrypt -eq -1 ]];then
  121. return
  122. fi
  123. if [[ $encrypt -eq 0 ]];then
  124. if $MY_PRINT_DEFAULTS xtrabackup | grep -q encrypt;then
  125. wsrep_log_error "Unexpected option combination. SST may fail. Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html"
  126. fi
  127. return
  128. fi
  129. if [[ $sfmt == 'tar' ]];then
  130. wsrep_log_info "NOTE: Xtrabackup-based encryption - encrypt=1 - cannot be enabled with tar format"
  131. encrypt=-1
  132. return
  133. fi
  134. wsrep_log_info "Xtrabackup based encryption enabled in my.cnf - Supported only from Xtrabackup 2.1.4"
  135. if [[ -z $ealgo ]];then
  136. wsrep_log_error "FATAL: Encryption algorithm empty from my.cnf, bailing out"
  137. exit 3
  138. fi
  139. if [[ -z $ekey && ! -r $ekeyfile ]];then
  140. wsrep_log_error "FATAL: Either key or keyfile must be readable"
  141. exit 3
  142. fi
  143. if [[ -z $ekey ]];then
  144. ecmd="${XBCRYPT_BIN} --encrypt-algo=$ealgo --encrypt-key-file=$ekeyfile"
  145. else
  146. ecmd="${XBCRYPT_BIN} --encrypt-algo=$ealgo --encrypt-key=$ekey"
  147. fi
  148. if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
  149. ecmd+=" -d"
  150. fi
  151. stagemsg+="-XB-Encrypted"
  152. }
  153. get_transfer()
  154. {
  155. if [[ -z $SST_PORT ]];then
  156. TSST_PORT=4444
  157. else
  158. TSST_PORT=$SST_PORT
  159. fi
  160. if [[ $tfmt == 'nc' ]];then
  161. wsrep_check_programs nc
  162. wsrep_log_info "Using netcat as streamer"
  163. if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
  164. if nc -h 2>&1 | grep -q ncat;then
  165. # Ncat
  166. tcmd="nc -l ${TSST_PORT}"
  167. elif nc -h 2>&1 | grep -qw -- '-d\>';then
  168. # Debian netcat
  169. if [ $WSREP_SST_OPT_HOST_IPv6 -eq 1 ];then
  170. # When host is not explicitly specified (when only the port
  171. # is specified) netcat can only bind to an IPv4 address if
  172. # the "-6" option is not explicitly specified:
  173. tcmd="nc -dl -6 ${TSST_PORT}"
  174. else
  175. tcmd="nc -dl ${TSST_PORT}"
  176. fi
  177. else
  178. # traditional netcat
  179. tcmd="nc -l -p ${TSST_PORT}"
  180. fi
  181. else
  182. # Check to see if netcat supports the '-N' flag.
  183. # -N Shutdown the network socket after EOF on stdin
  184. # If it supports the '-N' flag, then we need to use the '-N'
  185. # flag, otherwise the transfer will stay open after the file
  186. # transfer and cause the command to timeout.
  187. # Older versions of netcat did not need this flag and will
  188. # return an error if the flag is used.
  189. #
  190. tcmd_extra=""
  191. if nc -h 2>&1 | grep -qw -- -N; then
  192. tcmd_extra+="-N"
  193. wsrep_log_info "Using nc -N"
  194. fi
  195. # netcat doesn't understand [] around IPv6 address
  196. if nc -h 2>&1 | grep -q ncat;then
  197. # Ncat
  198. wsrep_log_info "Using Ncat as streamer"
  199. tcmd="nc ${tcmd_extra} ${WSREP_SST_OPT_HOST_UNESCAPED} ${TSST_PORT}"
  200. elif nc -h 2>&1 | grep -qw -- '-d\>';then
  201. # Debian netcat
  202. wsrep_log_info "Using Debian netcat as streamer"
  203. tcmd="nc ${tcmd_extra} ${WSREP_SST_OPT_HOST_UNESCAPED} ${TSST_PORT}"
  204. else
  205. # traditional netcat
  206. wsrep_log_info "Using traditional netcat as streamer"
  207. tcmd="nc -q0 ${tcmd_extra} ${WSREP_SST_OPT_HOST_UNESCAPED} ${TSST_PORT}"
  208. fi
  209. fi
  210. else
  211. tfmt='socat'
  212. wsrep_check_programs socat
  213. wsrep_log_info "Using socat as streamer"
  214. if [[ $encrypt -eq 2 || $encrypt -eq 3 ]] && ! socat -V | grep -q "WITH_OPENSSL 1";then
  215. wsrep_log_error "Encryption requested, but socat is not OpenSSL enabled (encrypt=$encrypt)"
  216. exit 2
  217. fi
  218. if [[ $encrypt -eq 2 ]];then
  219. wsrep_log_info "Using openssl based encryption with socat: with crt and pem"
  220. if [[ -z $tpem || -z $tcert ]];then
  221. wsrep_log_error "Both PEM and CRT files required"
  222. exit 22
  223. fi
  224. stagemsg+="-OpenSSL-Encrypted-2"
  225. if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
  226. wsrep_log_info "Decrypting with cert=${tpem}, cafile=${tcert}"
  227. tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tpem},cafile=${tcert}${sockopt} stdio"
  228. else
  229. wsrep_log_info "Encrypting with cert=${tpem}, cafile=${tcert}"
  230. tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${tpem},cafile=${tcert}${sockopt}"
  231. fi
  232. elif [[ $encrypt -eq 3 ]];then
  233. wsrep_log_info "Using openssl based encryption with socat: with key and crt"
  234. if [[ -z $tpem || -z $tkey ]];then
  235. wsrep_log_error "Both certificate and key files required"
  236. exit 22
  237. fi
  238. stagemsg+="-OpenSSL-Encrypted-3"
  239. if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
  240. if [[ -z $tcert ]];then
  241. wsrep_log_info "Decrypting with cert=${tpem}, key=${tkey}, verify=0"
  242. tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tpem},key=${tkey},verify=0${sockopt} stdio"
  243. else
  244. wsrep_log_info "Decrypting with cert=${tpem}, key=${tkey}, cafile=${tcert}"
  245. tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tpem},key=${tkey},cafile=${tcert}${sockopt} stdio"
  246. fi
  247. else
  248. if [[ -z $tcert ]];then
  249. wsrep_log_info "Encrypting with cert=${tpem}, key=${tkey}, verify=0"
  250. tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${tpem},key=${tkey},verify=0${sockopt}"
  251. else
  252. wsrep_log_info "Encrypting with cert=${tpem}, key=${tkey}, cafile=${tcert}"
  253. tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${tpem},key=${tkey},cafile=${tcert}${sockopt}"
  254. fi
  255. fi
  256. else
  257. if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
  258. tcmd="socat -u TCP-LISTEN:${TSST_PORT},reuseaddr${sockopt} stdio"
  259. else
  260. tcmd="socat -u stdio TCP:${REMOTEIP}:${TSST_PORT}${sockopt}"
  261. fi
  262. fi
  263. fi
  264. }
  265. parse_cnf()
  266. {
  267. local group=$1
  268. local var=$2
  269. # print the default settings for given group using my_print_default.
  270. # normalize the variable names specified in cnf file (user can use _ or - for example log-bin or log_bin)
  271. # then grep for needed variable
  272. # finally get the variable value (if variables has been specified multiple time use the last value only)
  273. reval=$($MY_PRINT_DEFAULTS $group | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2- | tail -1)
  274. if [[ -z $reval ]];then
  275. [[ -n $3 ]] && reval=$3
  276. fi
  277. echo $reval
  278. }
  279. get_footprint()
  280. {
  281. pushd $WSREP_SST_OPT_DATA 1>/dev/null
  282. payload=$(find . -regex '.*\.ibd$\|.*\.MYI$\|.*\.MYD$\|.*ibdata1$' -type f -print0 | du --files0-from=- --block-size=1 -c | awk 'END { print $1 }')
  283. if $MY_PRINT_DEFAULTS xtrabackup | grep -q -- "--compress";then
  284. # QuickLZ has around 50% compression ratio
  285. # When compression/compaction used, the progress is only an approximate.
  286. payload=$(( payload*1/2 ))
  287. fi
  288. popd 1>/dev/null
  289. pcmd+=" -s $payload"
  290. adjust_progress
  291. }
  292. adjust_progress()
  293. {
  294. if ! command -v pv >/dev/null;then
  295. wsrep_log_error "pv not found in path: $PATH"
  296. wsrep_log_error "Disabling all progress/rate-limiting"
  297. pcmd=""
  298. rlimit=""
  299. progress=""
  300. return
  301. fi
  302. if [[ -n $progress && $progress != '1' ]];then
  303. if [[ -e $progress ]];then
  304. pcmd+=" 2>>$progress"
  305. else
  306. pcmd+=" 2>$progress"
  307. fi
  308. elif [[ -z $progress && -n $rlimit ]];then
  309. # When rlimit is non-zero
  310. pcmd="pv -q"
  311. fi
  312. if [[ -n $rlimit && "$WSREP_SST_OPT_ROLE" == "donor" ]];then
  313. wsrep_log_info "Rate-limiting SST to $rlimit"
  314. pcmd+=" -L \$rlimit"
  315. fi
  316. }
  317. read_cnf()
  318. {
  319. sfmt=$(parse_cnf sst streamfmt "xbstream")
  320. tfmt=$(parse_cnf sst transferfmt "socat")
  321. tcert=$(parse_cnf sst tca "")
  322. tpem=$(parse_cnf sst tcert "")
  323. tkey=$(parse_cnf sst tkey "")
  324. encrypt=$(parse_cnf sst encrypt 0)
  325. sockopt=$(parse_cnf sst sockopt "")
  326. progress=$(parse_cnf sst progress "")
  327. rebuild=$(parse_cnf sst rebuild 0)
  328. ttime=$(parse_cnf sst time 0)
  329. cpat=$(parse_cnf sst cpat '.*galera\.cache$\|.*sst_in_progress$\|.*\.sst$\|.*gvwstate\.dat$\|.*grastate\.dat$\|.*\.err$\|.*\.log$\|.*RPM_UPGRADE_MARKER$\|.*RPM_UPGRADE_HISTORY$')
  330. [[ $OS == "FreeBSD" ]] && cpat=$(parse_cnf sst cpat '.*galera\.cache$|.*sst_in_progress$|.*\.sst$|.*gvwstate\.dat$|.*grastate\.dat$|.*\.err$|.*\.log$|.*RPM_UPGRADE_MARKER$|.*RPM_UPGRADE_HISTORY$')
  331. ealgo=$(parse_cnf xtrabackup encrypt "")
  332. ekey=$(parse_cnf xtrabackup encrypt-key "")
  333. ekeyfile=$(parse_cnf xtrabackup encrypt-key-file "")
  334. scomp=$(parse_cnf sst compressor "")
  335. sdecomp=$(parse_cnf sst decompressor "")
  336. # Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html
  337. if [[ -z $ealgo ]];then
  338. ealgo=$(parse_cnf sst encrypt-algo "")
  339. ekey=$(parse_cnf sst encrypt-key "")
  340. ekeyfile=$(parse_cnf sst encrypt-key-file "")
  341. fi
  342. rlimit=$(parse_cnf sst rlimit "")
  343. uextra=$(parse_cnf sst use-extra 0)
  344. speciald=$(parse_cnf sst sst-special-dirs 1)
  345. iopts=$(parse_cnf sst inno-backup-opts "")
  346. iapts=$(parse_cnf sst inno-apply-opts "")
  347. impts=$(parse_cnf sst inno-move-opts "")
  348. stimeout=$(parse_cnf sst sst-initial-timeout 300)
  349. ssyslog=$(parse_cnf sst sst-syslog 0)
  350. ssystag=$(parse_cnf mysqld_safe syslog-tag "${SST_SYSLOG_TAG:-}")
  351. ssystag+="-"
  352. sstlogarchive=$(parse_cnf sst sst-log-archive 1)
  353. sstlogarchivedir=$(parse_cnf sst sst-log-archive-dir "/tmp/sst_log_archive")
  354. if [[ $speciald -eq 0 ]];then
  355. wsrep_log_error "sst-special-dirs equal to 0 is not supported, falling back to 1"
  356. speciald=1
  357. fi
  358. if [[ $ssyslog -ne -1 ]];then
  359. if $MY_PRINT_DEFAULTS mysqld_safe | tr '_' '-' | grep -q -- "--syslog";then
  360. ssyslog=1
  361. fi
  362. fi
  363. if [[ $encrypt -eq 1 ]]; then
  364. wsrep_log_error "Xtrabackup-based encryption is currently not" \
  365. "supported with MariaBackup"
  366. exit 2
  367. fi
  368. }
  369. get_stream()
  370. {
  371. if [[ $sfmt == 'mbstream' || $sfmt == 'xbstream' ]];then
  372. wsrep_log_info "Streaming with ${sfmt}"
  373. if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
  374. strmcmd="${XBSTREAM_BIN} -x"
  375. else
  376. strmcmd="${XBSTREAM_BIN} -c \${INFO_FILE}"
  377. fi
  378. else
  379. sfmt="tar"
  380. wsrep_log_info "Streaming with tar"
  381. if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
  382. strmcmd="tar xfi - "
  383. else
  384. strmcmd="tar cf - \${INFO_FILE} "
  385. fi
  386. fi
  387. }
  388. get_proc()
  389. {
  390. set +e
  391. nproc=$(grep -c processor /proc/cpuinfo)
  392. [[ -z $nproc || $nproc -eq 0 ]] && nproc=1
  393. set -e
  394. }
  395. sig_joiner_cleanup()
  396. {
  397. wsrep_log_error "Removing $MAGIC_FILE file due to signal"
  398. rm -f "$MAGIC_FILE"
  399. }
  400. cleanup_joiner()
  401. {
  402. # Since this is invoked just after exit NNN
  403. local estatus=$?
  404. if [[ $estatus -ne 0 ]];then
  405. wsrep_log_error "Cleanup after exit with status:$estatus"
  406. elif [ "${WSREP_SST_OPT_ROLE}" = "joiner" ];then
  407. wsrep_log_info "Removing the sst_in_progress file"
  408. wsrep_cleanup_progress_file
  409. fi
  410. if [[ -n $progress && -p $progress ]];then
  411. wsrep_log_info "Cleaning up fifo file $progress"
  412. rm $progress
  413. fi
  414. if [[ -n ${STATDIR:-} ]];then
  415. [[ -d $STATDIR ]] && rm -rf $STATDIR
  416. fi
  417. # Final cleanup
  418. pgid=$(ps -o pgid= $$ | grep -o '[0-9]*')
  419. # This means no setsid done in mysqld.
  420. # We don't want to kill mysqld here otherwise.
  421. if [[ $$ -eq $pgid ]];then
  422. # This means a signal was delivered to the process.
  423. # So, more cleanup.
  424. if [[ $estatus -ge 128 ]];then
  425. kill -KILL -$$ || true
  426. fi
  427. fi
  428. exit $estatus
  429. }
  430. check_pid()
  431. {
  432. local pid_file="$1"
  433. [ -r "$pid_file" ] && ps -p $(cat "$pid_file") >/dev/null 2>&1
  434. }
  435. cleanup_donor()
  436. {
  437. # Since this is invoked just after exit NNN
  438. local estatus=$?
  439. if [[ $estatus -ne 0 ]];then
  440. wsrep_log_error "Cleanup after exit with status:$estatus"
  441. fi
  442. if [[ -n ${XTRABACKUP_PID:-} ]];then
  443. if check_pid $XTRABACKUP_PID
  444. then
  445. wsrep_log_error "xtrabackup process is still running. Killing..."
  446. kill_xtrabackup
  447. fi
  448. fi
  449. rm -f ${DATA}/${IST_FILE} || true
  450. if [[ -n $progress && -p $progress ]];then
  451. wsrep_log_info "Cleaning up fifo file $progress"
  452. rm -f $progress || true
  453. fi
  454. wsrep_log_info "Cleaning up temporary directories"
  455. if [[ -n $xtmpdir ]];then
  456. [[ -d $xtmpdir ]] && rm -rf $xtmpdir || true
  457. fi
  458. if [[ -n $itmpdir ]];then
  459. [[ -d $itmpdir ]] && rm -rf $itmpdir || true
  460. fi
  461. # Final cleanup
  462. pgid=$(ps -o pgid= $$ | grep -o '[0-9]*')
  463. # This means no setsid done in mysqld.
  464. # We don't want to kill mysqld here otherwise.
  465. if [[ $$ -eq $pgid ]];then
  466. # This means a signal was delivered to the process.
  467. # So, more cleanup.
  468. if [[ $estatus -ge 128 ]];then
  469. kill -KILL -$$ || true
  470. fi
  471. fi
  472. exit $estatus
  473. }
  474. kill_xtrabackup()
  475. {
  476. local PID=$(cat $XTRABACKUP_PID)
  477. [ -n "$PID" -a "0" != "$PID" ] && kill $PID && (kill $PID && kill -9 $PID) || :
  478. wsrep_log_info "Removing xtrabackup pid file $XTRABACKUP_PID"
  479. rm -f "$XTRABACKUP_PID" || true
  480. }
  481. setup_ports()
  482. {
  483. SST_PORT=${WSREP_SST_OPT_ADDR_PORT}
  484. if [[ "$WSREP_SST_OPT_ROLE" == "donor" ]];then
  485. REMOTEIP=${WSREP_SST_OPT_HOST}
  486. lsn=${WSREP_SST_OPT_LSN}
  487. sst_ver=${WSREP_SST_OPT_SST_VER}
  488. fi
  489. }
  490. # waits ~10 seconds for nc to open the port and then reports ready
  491. # (regardless of timeout)
  492. wait_for_listen()
  493. {
  494. local PORT=$1
  495. local ADDR=$2
  496. local MODULE=$3
  497. for i in {1..50}
  498. do
  499. if [ "$OS" = "FreeBSD" ];then
  500. sockstat -46lp $PORT | grep -qE "^[^ ]* *(socat|nc) *[^ ]* *[^ ]* *[^ ]* *[^ ]*:$PORT" && break
  501. else
  502. ss -p state listening "( sport = :$PORT )" | grep -qE 'socat|nc' && break
  503. fi
  504. sleep 0.2
  505. done
  506. echo "ready ${ADDR}/${MODULE}//$sst_ver"
  507. }
  508. check_extra()
  509. {
  510. local use_socket=1
  511. if [[ $uextra -eq 1 ]];then
  512. if $MY_PRINT_DEFAULTS --mysqld | tr '_' '-' | grep -- "--thread-handling=" | grep -q 'pool-of-threads';then
  513. local eport=$($MY_PRINT_DEFAULTS --mysqld | tr '_' '-' | grep -- "--extra-port=" | cut -d= -f2)
  514. if [[ -n $eport ]];then
  515. # Xtrabackup works only locally.
  516. # Hence, setting host to 127.0.0.1 unconditionally.
  517. wsrep_log_info "SST through extra_port $eport"
  518. INNOEXTRA+=" --host=127.0.0.1 --port=$eport"
  519. use_socket=0
  520. else
  521. wsrep_log_error "Extra port $eport null, failing"
  522. exit 1
  523. fi
  524. else
  525. wsrep_log_info "Thread pool not set, ignore the option use_extra"
  526. fi
  527. fi
  528. if [[ $use_socket -eq 1 ]] && [[ -n "$WSREP_SST_OPT_SOCKET" ]];then
  529. INNOEXTRA+=" --socket=$WSREP_SST_OPT_SOCKET"
  530. fi
  531. }
  532. recv_joiner()
  533. {
  534. local dir=$1
  535. local msg=$2
  536. local tmt=$3
  537. local checkf=$4
  538. local ltcmd
  539. if [[ ! -d ${dir} ]];then
  540. # This indicates that IST is in progress
  541. return
  542. fi
  543. pushd ${dir} 1>/dev/null
  544. set +e
  545. if [[ $tmt -gt 0 ]] && command -v timeout >/dev/null;then
  546. if timeout --help | grep -q -- '-k';then
  547. ltcmd="timeout -k $(( tmt+10 )) $tmt $tcmd"
  548. else
  549. ltcmd="timeout -s9 $tmt $tcmd"
  550. fi
  551. timeit "$msg" "$ltcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
  552. else
  553. timeit "$msg" "$tcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
  554. fi
  555. set -e
  556. popd 1>/dev/null
  557. if [[ ${RC[0]} -eq 124 ]];then
  558. wsrep_log_error "Possible timeout in receiving first data from "
  559. "donor in gtid stage: exit codes: ${RC[@]}"
  560. exit 32
  561. fi
  562. for ecode in "${RC[@]}";do
  563. if [[ $ecode -ne 0 ]];then
  564. wsrep_log_error "Error while getting data from donor node: " \
  565. "exit codes: ${RC[@]}"
  566. exit 32
  567. fi
  568. done
  569. if [[ $checkf -eq 1 && ! -r "${MAGIC_FILE}" ]];then
  570. # this message should cause joiner to abort
  571. wsrep_log_error "xtrabackup process ended without creating '${MAGIC_FILE}'"
  572. wsrep_log_info "Contents of datadir"
  573. wsrep_log_info "$(ls -l ${dir}/*)"
  574. exit 32
  575. fi
  576. }
  577. send_donor()
  578. {
  579. local dir=$1
  580. local msg=$2
  581. pushd ${dir} 1>/dev/null
  582. set +e
  583. timeit "$msg" "$strmcmd | $tcmd; RC=( "\${PIPESTATUS[@]}" )"
  584. set -e
  585. popd 1>/dev/null
  586. for ecode in "${RC[@]}";do
  587. if [[ $ecode -ne 0 ]];then
  588. wsrep_log_error "Error while getting data from donor node: " \
  589. "exit codes: ${RC[@]}"
  590. exit 32
  591. fi
  592. done
  593. }
  594. monitor_process()
  595. {
  596. local sst_stream_pid=$1
  597. while true ; do
  598. if ! ps -p "${WSREP_SST_OPT_PARENT}" &>/dev/null; then
  599. wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly."
  600. exit 32
  601. fi
  602. if ! ps -p "${sst_stream_pid}" &>/dev/null; then
  603. break
  604. fi
  605. sleep 0.1
  606. done
  607. }
  608. wsrep_check_programs "$INNOBACKUPEX_BIN"
  609. rm -f "${MAGIC_FILE}"
  610. if [[ ! ${WSREP_SST_OPT_ROLE} == 'joiner' && ! ${WSREP_SST_OPT_ROLE} == 'donor' ]];then
  611. wsrep_log_error "Invalid role ${WSREP_SST_OPT_ROLE}"
  612. exit 22
  613. fi
  614. read_cnf
  615. setup_ports
  616. if ${INNOBACKUPEX_BIN} /tmp --help 2>/dev/null | grep -q -- '--version-check'; then
  617. disver="--no-version-check"
  618. fi
  619. iopts+=" --databases-exclude=\"lost+found\""
  620. if [[ ${FORCE_FTWRL:-0} -eq 1 ]];then
  621. wsrep_log_info "Forcing FTWRL due to environment variable FORCE_FTWRL equal to $FORCE_FTWRL"
  622. iopts+=" --no-backup-locks"
  623. fi
  624. INNOEXTRA=$WSREP_SST_OPT_MYSQLD
  625. INNODB_DATA_HOME_DIR=${INNODB_DATA_HOME_DIR:-""}
  626. # Try to set INNODB_DATA_HOME_DIR from the command line:
  627. if [ ! -z "$INNODB_DATA_HOME_DIR_ARG" ]; then
  628. INNODB_DATA_HOME_DIR=$INNODB_DATA_HOME_DIR_ARG
  629. fi
  630. # if no command line arg and INNODB_DATA_HOME_DIR environment variable
  631. # is not set, try to get it from my.cnf:
  632. if [ -z "$INNODB_DATA_HOME_DIR" ]; then
  633. INNODB_DATA_HOME_DIR=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE innodb-data-home-dir '')
  634. fi
  635. if [ -z "$INNODB_DATA_HOME_DIR" ]; then
  636. INNODB_DATA_HOME_DIR=$(parse_cnf --mysqld innodb-data-home-dir '')
  637. fi
  638. if [ ! -z "$INNODB_DATA_HOME_DIR" ]; then
  639. INNOEXTRA+=" --innodb-data-home-dir=$INNODB_DATA_HOME_DIR"
  640. fi
  641. if [ -n "$INNODB_DATA_HOME_DIR" ]; then
  642. # handle both relative and absolute paths
  643. INNODB_DATA_HOME_DIR=$(cd $DATA; mkdir -p "$INNODB_DATA_HOME_DIR"; cd $INNODB_DATA_HOME_DIR; pwd -P)
  644. else
  645. # default to datadir
  646. INNODB_DATA_HOME_DIR=$(cd $DATA; pwd -P)
  647. fi
  648. if [[ $ssyslog -eq 1 ]];then
  649. if ! command -v logger >/dev/null;then
  650. wsrep_log_error "logger not in path: $PATH. Ignoring"
  651. else
  652. wsrep_log_info "Logging all stderr of SST/Innobackupex to syslog"
  653. exec 2> >(logger -p daemon.err -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE)
  654. wsrep_log_error()
  655. {
  656. logger -p daemon.err -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE "$@"
  657. }
  658. wsrep_log_info()
  659. {
  660. logger -p daemon.info -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE "$@"
  661. }
  662. INNOAPPLY="${INNOBACKUPEX_BIN} --innobackupex $disver $iapts \$INNOEXTRA --apply-log \$rebuildcmd \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-apply"
  663. INNOMOVE="${INNOBACKUPEX_BIN} --innobackupex ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-move"
  664. INNOBACKUP="${INNOBACKUPEX_BIN} --innobackupex ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2> >(logger -p daemon.err -t ${ssystag}innobackupex-backup)"
  665. fi
  666. else
  667. if [[ "$sstlogarchive" -eq 1 ]]
  668. then
  669. ARCHIVETIMESTAMP=$(date "+%Y.%m.%d-%H.%M.%S.%N")
  670. newfile=""
  671. if [[ ! -z "$sstlogarchivedir" ]]
  672. then
  673. if [[ ! -d "$sstlogarchivedir" ]]
  674. then
  675. mkdir -p "$sstlogarchivedir"
  676. fi
  677. fi
  678. if [ -e "${INNOAPPLYLOG}" ]
  679. then
  680. if [[ ! -z "$sstlogarchivedir" ]]
  681. then
  682. newfile=$sstlogarchivedir/$(basename "${INNOAPPLYLOG}").${ARCHIVETIMESTAMP}
  683. else
  684. newfile=${INNOAPPLYLOG}.${ARCHIVETIMESTAMP}
  685. fi
  686. wsrep_log_info "Moving ${INNOAPPLYLOG} to ${newfile}"
  687. mv "${INNOAPPLYLOG}" "${newfile}"
  688. gzip "${newfile}"
  689. fi
  690. if [ -e "${INNOMOVELOG}" ]
  691. then
  692. if [[ ! -z "$sstlogarchivedir" ]]
  693. then
  694. newfile=$sstlogarchivedir/$(basename "${INNOMOVELOG}").${ARCHIVETIMESTAMP}
  695. else
  696. newfile=${INNOMOVELOG}.${ARCHIVETIMESTAMP}
  697. fi
  698. wsrep_log_info "Moving ${INNOMOVELOG} to ${newfile}"
  699. mv "${INNOMOVELOG}" "${newfile}"
  700. gzip "${newfile}"
  701. fi
  702. if [ -e "${INNOBACKUPLOG}" ]
  703. then
  704. if [[ ! -z "$sstlogarchivedir" ]]
  705. then
  706. newfile=$sstlogarchivedir/$(basename "${INNOBACKUPLOG}").${ARCHIVETIMESTAMP}
  707. else
  708. newfile=${INNOBACKUPLOG}.${ARCHIVETIMESTAMP}
  709. fi
  710. wsrep_log_info "Moving ${INNOBACKUPLOG} to ${newfile}"
  711. mv "${INNOBACKUPLOG}" "${newfile}"
  712. gzip "${newfile}"
  713. fi
  714. fi
  715. INNOAPPLY="${INNOBACKUPEX_BIN} --innobackupex $disver $iapts \$INNOEXTRA --apply-log \$rebuildcmd \${DATA} &> ${INNOAPPLYLOG}"
  716. INNOMOVE="${INNOBACKUPEX_BIN} --innobackupex ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} &> ${INNOMOVELOG}"
  717. INNOBACKUP="${INNOBACKUPEX_BIN} --innobackupex ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2> ${INNOBACKUPLOG}"
  718. fi
  719. get_stream
  720. get_transfer
  721. if [ "$WSREP_SST_OPT_ROLE" = "donor" ]
  722. then
  723. trap cleanup_donor EXIT
  724. if [ $WSREP_SST_OPT_BYPASS -eq 0 ]
  725. then
  726. usrst=0
  727. if [[ -z $sst_ver ]];then
  728. wsrep_log_error "Upgrade joiner to 5.6.21 or higher for backup locks support"
  729. wsrep_log_error "The joiner is not supported for this version of donor"
  730. exit 93
  731. fi
  732. if [[ -z $(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE tmpdir "") && \
  733. -z $(parse_cnf --mysqld tmpdir "") && \
  734. -z $(parse_cnf xtrabackup tmpdir "") ]]; then
  735. xtmpdir=$(mktemp -d)
  736. tmpopts=" --tmpdir=$xtmpdir"
  737. wsrep_log_info "Using $xtmpdir as xtrabackup temporary directory"
  738. fi
  739. itmpdir=$(mktemp -d)
  740. wsrep_log_info "Using $itmpdir as innobackupex temporary directory"
  741. if [[ -n "${WSREP_SST_OPT_USER:-}" && "$WSREP_SST_OPT_USER" != "(null)" ]]; then
  742. INNOEXTRA+=" --user=$WSREP_SST_OPT_USER"
  743. usrst=1
  744. fi
  745. if [ -n "${WSREP_SST_OPT_PSWD:-}" ]; then
  746. INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD"
  747. elif [[ $usrst -eq 1 ]];then
  748. # Empty password, used for testing, debugging etc.
  749. INNOEXTRA+=" --password="
  750. fi
  751. get_keys
  752. if [[ $encrypt -eq 1 ]];then
  753. if [[ -n $ekey ]];then
  754. INNOEXTRA+=" --encrypt=$ealgo --encrypt-key=$ekey"
  755. else
  756. INNOEXTRA+=" --encrypt=$ealgo --encrypt-key-file=$ekeyfile"
  757. fi
  758. fi
  759. check_extra
  760. wsrep_log_info "Streaming GTID file before SST"
  761. # Store donor's wsrep GTID (state ID) and wsrep_gtid_domain_id
  762. # (separated by a space).
  763. echo "${WSREP_SST_OPT_GTID} ${WSREP_SST_OPT_GTID_DOMAIN_ID}" > "${MAGIC_FILE}"
  764. ttcmd="$tcmd"
  765. if [[ $encrypt -eq 1 ]];then
  766. if [[ -n $scomp ]];then
  767. tcmd=" $ecmd | $scomp | $tcmd "
  768. else
  769. tcmd=" $ecmd | $tcmd "
  770. fi
  771. elif [[ -n $scomp ]];then
  772. tcmd=" $scomp | $tcmd "
  773. fi
  774. send_donor $DATA "${stagemsg}-gtid"
  775. tcmd="$ttcmd"
  776. if [[ -n $progress ]];then
  777. get_footprint
  778. tcmd="$pcmd | $tcmd"
  779. elif [[ -n $rlimit ]];then
  780. adjust_progress
  781. tcmd="$pcmd | $tcmd"
  782. fi
  783. wsrep_log_info "Sleeping before data transfer for SST"
  784. sleep 10
  785. wsrep_log_info "Streaming the backup to joiner at ${REMOTEIP} ${SST_PORT:-4444}"
  786. if [[ -n $scomp ]];then
  787. tcmd="$scomp | $tcmd"
  788. fi
  789. set +e
  790. timeit "${stagemsg}-SST" "$INNOBACKUP | $tcmd; RC=( "\${PIPESTATUS[@]}" )"
  791. set -e
  792. if [ ${RC[0]} -ne 0 ]; then
  793. wsrep_log_error "${INNOBACKUPEX_BIN} finished with error: ${RC[0]}. " \
  794. "Check syslog or ${INNOBACKUPLOG} for details"
  795. exit 22
  796. elif [[ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ]];then
  797. wsrep_log_error "$tcmd finished with error: ${RC[1]}"
  798. exit 22
  799. fi
  800. # innobackupex implicitly writes PID to fixed location in $xtmpdir
  801. XTRABACKUP_PID="$xtmpdir/xtrabackup_pid"
  802. else # BYPASS FOR IST
  803. wsrep_log_info "Bypassing the SST for IST"
  804. echo "continue" # now server can resume updating data
  805. # Store donor's wsrep GTID (state ID) and wsrep_gtid_domain_id
  806. # (separated by a space).
  807. echo "${WSREP_SST_OPT_GTID} ${WSREP_SST_OPT_GTID_DOMAIN_ID}" > "${MAGIC_FILE}"
  808. echo "1" > "${DATA}/${IST_FILE}"
  809. get_keys
  810. if [[ $encrypt -eq 1 ]];then
  811. if [[ -n $scomp ]];then
  812. tcmd=" $ecmd | $scomp | $tcmd "
  813. else
  814. tcmd=" $ecmd | $tcmd "
  815. fi
  816. elif [[ -n $scomp ]];then
  817. tcmd=" $scomp | $tcmd "
  818. fi
  819. strmcmd+=" \${IST_FILE}"
  820. send_donor $DATA "${stagemsg}-IST"
  821. fi
  822. echo "done ${WSREP_SST_OPT_GTID}"
  823. wsrep_log_info "Total time on donor: $totime seconds"
  824. elif [ "${WSREP_SST_OPT_ROLE}" = "joiner" ]
  825. then
  826. [[ -e $SST_PROGRESS_FILE ]] && wsrep_log_info "Stale sst_in_progress file: $SST_PROGRESS_FILE"
  827. [[ -n $SST_PROGRESS_FILE ]] && touch $SST_PROGRESS_FILE
  828. ib_home_dir=$INNODB_DATA_HOME_DIR
  829. WSREP_LOG_DIR=${WSREP_LOG_DIR:-""}
  830. # Try to set WSREP_LOG_DIR from the command line:
  831. if [ ! -z "$INNODB_LOG_GROUP_HOME_ARG" ]; then
  832. WSREP_LOG_DIR=$INNODB_LOG_GROUP_HOME_ARG
  833. fi
  834. # if no command line arg and WSREP_LOG_DIR is not set,
  835. # try to get it from my.cnf:
  836. if [ -z "$WSREP_LOG_DIR" ]; then
  837. WSREP_LOG_DIR=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE innodb-log-group-home-dir '')
  838. fi
  839. if [ -z "$WSREP_LOG_DIR" ]; then
  840. WSREP_LOG_DIR=$(parse_cnf --mysqld innodb-log-group-home-dir '')
  841. fi
  842. ib_log_dir=$WSREP_LOG_DIR
  843. # Try to set ib_undo_dir from the command line:
  844. ib_undo_dir=${INNODB_UNDO_DIR_ARG:-""}
  845. # if no command line arg then try to get it from my.cnf:
  846. if [ -z "$ib_undo_dir" ]; then
  847. ib_undo_dir=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE innodb-undo-directory "")
  848. fi
  849. if [ -z "$ib_undo_dir" ]; then
  850. ib_undo_dir=$(parse_cnf --mysqld innodb-undo-directory "")
  851. fi
  852. stagemsg="Joiner-Recv"
  853. sencrypted=1
  854. nthreads=1
  855. MODULE="xtrabackup_sst"
  856. rm -f "${DATA}/${IST_FILE}"
  857. # May need xtrabackup_checkpoints later on
  858. rm -f ${DATA}/xtrabackup_binary ${DATA}/xtrabackup_galera_info ${DATA}/ib_logfile0
  859. ADDR=${WSREP_SST_OPT_ADDR}
  860. if [ -z "${SST_PORT}" ]
  861. then
  862. SST_PORT=4444
  863. if [ "${ADDR#\[}" != "$ADDR" ]; then
  864. ADDR="$(echo ${WSREP_SST_OPT_ADDR} | awk -F '\\]:' '{ print $1 }')]:${SST_PORT}"
  865. else
  866. ADDR="$(echo ${WSREP_SST_OPT_ADDR} | awk -F ':' '{ print $1 }'):${SST_PORT}"
  867. fi
  868. fi
  869. wait_for_listen ${SST_PORT} ${ADDR} ${MODULE} &
  870. trap sig_joiner_cleanup HUP PIPE INT TERM
  871. trap cleanup_joiner EXIT
  872. if [[ -n $progress ]];then
  873. adjust_progress
  874. tcmd+=" | $pcmd"
  875. fi
  876. get_keys
  877. if [[ $encrypt -eq 1 && $sencrypted -eq 1 ]];then
  878. if [[ -n $sdecomp ]];then
  879. strmcmd=" $sdecomp | $ecmd | $strmcmd"
  880. else
  881. strmcmd=" $ecmd | $strmcmd"
  882. fi
  883. elif [[ -n $sdecomp ]];then
  884. strmcmd=" $sdecomp | $strmcmd"
  885. fi
  886. STATDIR=$(mktemp -d)
  887. MAGIC_FILE="${STATDIR}/${INFO_FILE}"
  888. recv_joiner $STATDIR "${stagemsg}-gtid" $stimeout 1
  889. if ! ps -p ${WSREP_SST_OPT_PARENT} &>/dev/null
  890. then
  891. wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly."
  892. exit 32
  893. fi
  894. if [ ! -r "${STATDIR}/${IST_FILE}" ]
  895. then
  896. if [[ -d ${DATA}/.sst ]];then
  897. wsrep_log_info "WARNING: Stale temporary SST directory: ${DATA}/.sst from previous state transfer. Removing"
  898. rm -rf ${DATA}/.sst
  899. fi
  900. mkdir -p ${DATA}/.sst
  901. (recv_joiner $DATA/.sst "${stagemsg}-SST" 0 0) &
  902. jpid=$!
  903. wsrep_log_info "Proceeding with SST"
  904. wsrep_log_info "Cleaning the existing datadir and innodb-data/log directories"
  905. if [ "${OS}" = "FreeBSD" ]; then
  906. find -E $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1 -prune -regex $cpat -o -exec rm -rfv {} 1>&2 \+
  907. else
  908. find $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1 -prune -regex $cpat -o -exec rm -rfv {} 1>&2 \+
  909. fi
  910. tempdir=$LOG_BIN_ARG
  911. if [ -z "$tempdir" ]; then
  912. tempdir=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE log-bin "")
  913. fi
  914. if [ -z "$tempdir" ]; then
  915. tempdir=$(parse_cnf --mysqld log-bin "")
  916. fi
  917. if [[ -n ${tempdir:-} ]];then
  918. binlog_dir=$(dirname $tempdir)
  919. binlog_file=$(basename $tempdir)
  920. if [[ -n ${binlog_dir:-} && $binlog_dir != '.' && $binlog_dir != $DATA ]];then
  921. pattern="$binlog_dir/$binlog_file\.[0-9]+$"
  922. wsrep_log_info "Cleaning the binlog directory $binlog_dir as well"
  923. find $binlog_dir -maxdepth 1 -type f -regex $pattern -exec rm -fv {} 1>&2 \+ || true
  924. rm $binlog_dir/*.index || true
  925. fi
  926. fi
  927. TDATA=${DATA}
  928. DATA="${DATA}/.sst"
  929. MAGIC_FILE="${DATA}/${INFO_FILE}"
  930. wsrep_log_info "Waiting for SST streaming to complete!"
  931. monitor_process $jpid
  932. get_proc
  933. if [[ ! -s ${DATA}/xtrabackup_checkpoints ]];then
  934. wsrep_log_error "xtrabackup_checkpoints missing, failed innobackupex/SST on donor"
  935. exit 2
  936. fi
  937. # Rebuild indexes for compact backups
  938. if grep -q 'compact = 1' ${DATA}/xtrabackup_checkpoints;then
  939. wsrep_log_info "Index compaction detected"
  940. rebuild=1
  941. fi
  942. if [[ $rebuild -eq 1 ]];then
  943. nthreads=$(parse_cnf xtrabackup rebuild-threads $nproc)
  944. wsrep_log_info "Rebuilding during prepare with $nthreads threads"
  945. rebuildcmd="--rebuild-indexes --rebuild-threads=$nthreads"
  946. fi
  947. if test -n "$(find ${DATA} -maxdepth 1 -type f -name '*.qp' -print -quit)";then
  948. wsrep_log_info "Compressed qpress files found"
  949. if ! command -v qpress >/dev/null;then
  950. wsrep_log_error "qpress not found in path: $PATH"
  951. exit 22
  952. fi
  953. if [[ -n $progress ]] && pv --help | grep -q 'line-mode';then
  954. count=$(find ${DATA} -type f -name '*.qp' | wc -l)
  955. count=$(( count*2 ))
  956. if pv --help | grep -q FORMAT;then
  957. pvopts="-f -s $count -l -N Decompression -F '%N => Rate:%r Elapsed:%t %e Progress: [%b/$count]'"
  958. else
  959. pvopts="-f -s $count -l -N Decompression"
  960. fi
  961. pcmd="pv $pvopts"
  962. adjust_progress
  963. dcmd="$pcmd | xargs -n 2 qpress -T${nproc}d"
  964. else
  965. dcmd="xargs -n 2 qpress -T${nproc}d"
  966. fi
  967. # Decompress the qpress files
  968. wsrep_log_info "Decompression with $nproc threads"
  969. timeit "Joiner-Decompression" "find ${DATA} -type f -name '*.qp' -printf '%p\n%h\n' | $dcmd"
  970. extcode=$?
  971. if [[ $extcode -eq 0 ]];then
  972. wsrep_log_info "Removing qpress files after decompression"
  973. find ${DATA} -type f -name '*.qp' -delete
  974. if [[ $? -ne 0 ]];then
  975. wsrep_log_error "Something went wrong with deletion of qpress files. Investigate"
  976. fi
  977. else
  978. wsrep_log_error "Decompression failed. Exit code: $extcode"
  979. exit 22
  980. fi
  981. fi
  982. if [[ ! -z $WSREP_SST_OPT_BINLOG ]];then
  983. BINLOG_DIRNAME=$(dirname $WSREP_SST_OPT_BINLOG)
  984. BINLOG_FILENAME=$(basename $WSREP_SST_OPT_BINLOG)
  985. # To avoid comparing data directory and BINLOG_DIRNAME
  986. mv $DATA/${BINLOG_FILENAME}.* $BINLOG_DIRNAME/ 2>/dev/null || true
  987. pushd $BINLOG_DIRNAME &>/dev/null
  988. for bfiles in $(ls -1 ${BINLOG_FILENAME}.[0-9]*);do
  989. echo ${BINLOG_DIRNAME}/${bfiles} >> ${BINLOG_FILENAME}.index
  990. done
  991. popd &> /dev/null
  992. fi
  993. wsrep_log_info "Preparing the backup at ${DATA}"
  994. timeit "Xtrabackup prepare stage" "$INNOAPPLY"
  995. if [ $? -ne 0 ];
  996. then
  997. wsrep_log_error "${INNOBACKUPEX_BIN} apply finished with errors. Check syslog or ${INNOAPPLYLOG} for details"
  998. exit 22
  999. fi
  1000. MAGIC_FILE="${TDATA}/${INFO_FILE}"
  1001. set +e
  1002. set -e
  1003. wsrep_log_info "Moving the backup to ${TDATA}"
  1004. timeit "Xtrabackup move stage" "$INNOMOVE"
  1005. if [[ $? -eq 0 ]];then
  1006. wsrep_log_info "Move successful, removing ${DATA}"
  1007. rm -rf $DATA
  1008. DATA=${TDATA}
  1009. else
  1010. wsrep_log_error "Move failed, keeping ${DATA} for further diagnosis"
  1011. wsrep_log_error "Check syslog or ${INNOMOVELOG} for details"
  1012. exit 22
  1013. fi
  1014. else
  1015. wsrep_log_info "${IST_FILE} received from donor: Running IST"
  1016. fi
  1017. if [[ ! -r ${MAGIC_FILE} ]];then
  1018. wsrep_log_error "SST magic file ${MAGIC_FILE} not found/readable"
  1019. exit 2
  1020. fi
  1021. wsrep_log_info "Galera co-ords from recovery: $(cat ${MAGIC_FILE})"
  1022. cat "${MAGIC_FILE}" # Output : UUID:seqno wsrep_gtid_domain_id
  1023. wsrep_log_info "Total time on joiner: $totime seconds"
  1024. fi
  1025. exit 0