summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2014-09-26 15:54:42 +0200
committerSergei Golubchik <serg@mariadb.org>2014-10-01 23:38:27 +0200
commit4bb49d84a9df8c3f29683bfe8503a575bc0ab84b (patch)
tree0c96f130ed7767063af8587809bce1f5d5ddc141
parentdc113e2765c19cc3b1dff7c6141701411c93ce42 (diff)
downloadmariadb-git-4bb49d84a9df8c3f29683bfe8503a575bc0ab84b.tar.gz
correct handling on defaults[-extra]-file is SST scripts
pass --defaults-file and --defaults-extra-file (whatever was specified, or none) from mysqld down to SST scripts. parse these options in SST scripts and pass them down to mysqldump, my_print_defaults, and xtrabackup
-rw-r--r--mysys/my_default.c12
-rw-r--r--scripts/wsrep_sst_common.sh16
-rw-r--r--scripts/wsrep_sst_mysqldump.sh4
-rw-r--r--scripts/wsrep_sst_rsync.sh4
-rw-r--r--scripts/wsrep_sst_xtrabackup-v2.sh16
-rw-r--r--scripts/wsrep_sst_xtrabackup.sh18
-rw-r--r--sql/wsrep_sst.cc33
-rw-r--r--sql/wsrep_sst.h1
8 files changed, 61 insertions, 43 deletions
diff --git a/mysys/my_default.c b/mysys/my_default.c
index 1a29fd87a34..1e4038d17fb 100644
--- a/mysys/my_default.c
+++ b/mysys/my_default.c
@@ -88,12 +88,6 @@ static char my_defaults_extra_file_buffer[FN_REFLEN];
static my_bool defaults_already_read= FALSE;
-#ifdef WITH_WSREP
-/* The only purpose of this global array is to hold full name of my.cnf
- * which seems to be otherwise unavailable */
-char wsrep_defaults_file[FN_REFLEN + 10]={0,};
-#endif /* WITH_WREP */
-
/* Which directories are searched for options (and in which order) */
#define MAX_DEFAULT_DIRS 6
@@ -810,12 +804,6 @@ static int search_default_file_with_ext(Process_option_func opt_handler,
if (!(fp= mysql_file_fopen(key_file_cnf, name, O_RDONLY, MYF(0))))
return 1; /* Ignore wrong files */
-#ifdef WITH_WSREP
- /* make sure we do this only once - for top-level file */
- if ('\0' == wsrep_defaults_file[0])
- strmake(wsrep_defaults_file, name, sizeof(wsrep_defaults_file) - 1);
-#endif /* WITH_WSREP */
-
while (mysql_file_fgets(buff, sizeof(buff) - 1, fp))
{
line++;
diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh
index 88f5d80f53a..574657f1a76 100644
--- a/scripts/wsrep_sst_common.sh
+++ b/scripts/wsrep_sst_common.sh
@@ -22,6 +22,9 @@ WSREP_SST_OPT_BYPASS=0
WSREP_SST_OPT_BINLOG=""
WSREP_SST_OPT_DATA=""
WSREP_SST_OPT_AUTH=""
+WSREP_SST_OPT_DEFAULT=""
+WSREP_SST_OPT_EXTRA_DEFAULT=""
+
while [ $# -gt 0 ]; do
case "$1" in
@@ -41,7 +44,11 @@ case "$1" in
shift
;;
'--defaults-file')
- readonly WSREP_SST_OPT_CONF="$2"
+ readonly WSREP_SST_OPT_DEFAULT="$1=$2"
+ shift
+ ;;
+ '--defaults-extra-file')
+ readonly WSREP_SST_OPT_EXTRA_DEFAULT="$1=$2"
shift
;;
'--host')
@@ -94,10 +101,13 @@ done
readonly WSREP_SST_OPT_BYPASS
readonly WSREP_SST_OPT_BINLOG
+readonly WSREP_SST_OPT_CONF="$WSREP_SST_OPT_DEFAULT $WSREP_SST_OPT_EXTRA_DEFAULT"
+readonly my_print_defaults="my_print_defaults $WSREP_SST_OPT_CONF"
+
# State Snapshot Transfer authentication password was displayed in the ps output. Bug fixed #1200727.
-if my_print_defaults -c $WSREP_SST_OPT_CONF sst | grep -q "wsrep_sst_auth";then
+if $my_print_defaults sst | grep -q "wsrep_sst_auth";then
if [ -z "$WSREP_SST_OPT_AUTH" -o "$WSREP_SST_OPT_AUTH" = "(null)" ];then
- WSREP_SST_OPT_AUTH=$(my_print_defaults -c $WSREP_SST_OPT_CONF sst | grep -- "--wsrep_sst_auth" | cut -d= -f2)
+ WSREP_SST_OPT_AUTH=$($my_print_defaults sst | grep -- "--wsrep_sst_auth" | cut -d= -f2)
fi
fi
diff --git a/scripts/wsrep_sst_mysqldump.sh b/scripts/wsrep_sst_mysqldump.sh
index d4093dbcaef..6a863d7714d 100644
--- a/scripts/wsrep_sst_mysqldump.sh
+++ b/scripts/wsrep_sst_mysqldump.sh
@@ -17,10 +17,6 @@
# This is a reference script for mysqldump-based state snapshot tansfer
-# This variable is not used in mysqldump sst, so better initialize it
-# to avoid shell's "parameter not set" message.
-WSREP_SST_OPT_CONF=""
-
. $(dirname $0)/wsrep_sst_common
EINVAL=22
diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh
index 86bf557662d..7bcc398c727 100644
--- a/scripts/wsrep_sst_rsync.sh
+++ b/scripts/wsrep_sst_rsync.sh
@@ -92,9 +92,7 @@ fi
WSREP_LOG_DIR=${WSREP_LOG_DIR:-""}
# if WSREP_LOG_DIR env. variable is not set, try to get it from my.cnf
if [ -z "$WSREP_LOG_DIR" ]; then
- SCRIPT_DIR="$(cd $(dirname "$0"); pwd -P)"
- WSREP_LOG_DIR=$($SCRIPT_DIR/my_print_defaults --defaults-file \
- "$WSREP_SST_OPT_CONF" mysqld server mysqld-10.0 mariadb mariadb-10.0 \
+ WSREP_LOG_DIR=$($my_print_defaults --mysqld \
| grep -- '--innodb[-_]log[-_]group[-_]home[-_]dir=' \
| cut -b 29- )
fi
diff --git a/scripts/wsrep_sst_xtrabackup-v2.sh b/scripts/wsrep_sst_xtrabackup-v2.sh
index f4d133d4f8e..dab0201f067 100644
--- a/scripts/wsrep_sst_xtrabackup-v2.sh
+++ b/scripts/wsrep_sst_xtrabackup-v2.sh
@@ -117,7 +117,7 @@ get_keys()
fi
if [[ $encrypt -eq 0 ]];then
- if my_print_defaults -c $WSREP_SST_OPT_CONF xtrabackup | grep -q encrypt;then
+ if $my_print_defaults xtrabackup | grep -q encrypt;then
wsrep_log_error "Unexpected option combination. SST may fail. Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html "
fi
return
@@ -230,7 +230,7 @@ parse_cnf()
{
local group=$1
local var=$2
- reval=$(my_print_defaults -c $WSREP_SST_OPT_CONF $group | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2-)
+ reval=$($my_print_defaults $group | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2-)
if [[ -z $reval ]];then
[[ -n $3 ]] && reval=$3
fi
@@ -241,7 +241,7 @@ get_footprint()
{
pushd $WSREP_SST_OPT_DATA 1>/dev/null
payload=$(find . -regex '.*\.ibd$\|.*\.MYI$\|.*\.MYD$\|.*ibdata1$' -type f -print0 | xargs -0 du --block-size=1 -c | awk 'END { print $1 }')
- if my_print_defaults -c $WSREP_SST_OPT_CONF xtrabackup | grep -q -- "--compress";then
+ if $my_print_defaults xtrabackup | grep -q -- "--compress";then
# QuickLZ has around 50% compression ratio
# When compression/compaction used, the progress is only an approximate.
payload=$(( payload*1/2 ))
@@ -443,8 +443,8 @@ check_extra()
{
local use_socket=1
if [[ $uextra -eq 1 ]];then
- if my_print_defaults -c $WSREP_SST_OPT_CONF mysqld | tr '_' '-' | grep -- "--thread-handling=" | grep -q 'pool-of-threads';then
- local eport=$(my_print_defaults -c $WSREP_SST_OPT_CONF mysqld | tr '_' '-' | grep -- "--extra-port=" | cut -d= -f2)
+ if $my_print_defaults --mysqld | tr '_' '-' | grep -- "--thread-handling=" | grep -q 'pool-of-threads';then
+ local eport=$($my_print_defaults --mysqld | tr '_' '-' | grep -- "--extra-port=" | cut -d= -f2)
if [[ -n $eport ]];then
# Xtrabackup works only locally.
# Hence, setting host to 127.0.0.1 unconditionally.
@@ -557,8 +557,8 @@ fi
INNOEXTRA=""
INNOAPPLY="${INNOBACKUPEX_BIN} $disver $iapts --apply-log \$rebuildcmd \${DATA} &>\${DATA}/innobackup.prepare.log"
-INNOMOVE="${INNOBACKUPEX_BIN} --defaults-file=${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} &>\${DATA}/innobackup.move.log"
-INNOBACKUP="${INNOBACKUPEX_BIN} --defaults-file=${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2>\${DATA}/innobackup.backup.log"
+INNOMOVE="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} &>\${DATA}/innobackup.move.log"
+INNOBACKUP="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2>\${DATA}/innobackup.backup.log"
if [ "$WSREP_SST_OPT_ROLE" = "donor" ]
then
@@ -879,7 +879,7 @@ then
if [[ $incremental -eq 1 ]];then
# Added --ibbackup=xtrabackup_55 because it fails otherwise citing connection issues.
- INNOAPPLY="${INNOBACKUPEX_BIN} $disver --defaults-file=${WSREP_SST_OPT_CONF} \
+ INNOAPPLY="${INNOBACKUPEX_BIN} $disver ${WSREP_SST_OPT_CONF} \
--ibbackup=xtrabackup_56 --apply-log $rebuildcmd --redo-only $BDATA --incremental-dir=${DATA} &>>${BDATA}/innobackup.prepare.log"
fi
diff --git a/scripts/wsrep_sst_xtrabackup.sh b/scripts/wsrep_sst_xtrabackup.sh
index 6b33eabee23..0aac7dc50d2 100644
--- a/scripts/wsrep_sst_xtrabackup.sh
+++ b/scripts/wsrep_sst_xtrabackup.sh
@@ -100,7 +100,7 @@ get_keys()
fi
if [[ $encrypt -eq 0 ]];then
- if my_print_defaults -c $WSREP_SST_OPT_CONF xtrabackup | grep -q encrypt;then
+ if $my_print_defaults xtrabackup | grep -q encrypt;then
wsrep_log_error "Unexpected option combination. SST may fail. Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html "
fi
return
@@ -195,7 +195,7 @@ parse_cnf()
{
local group=$1
local var=$2
- reval=$(my_print_defaults -c $WSREP_SST_OPT_CONF $group | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2-)
+ reval=$($my_print_defaults $group | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2-)
if [[ -z $reval ]];then
[[ -n $3 ]] && reval=$3
fi
@@ -206,7 +206,7 @@ get_footprint()
{
pushd $WSREP_SST_OPT_DATA 1>/dev/null
payload=$(find . -regex '.*\.ibd$\|.*\.MYI$\|.*\.MYD$\|.*ibdata1$' -type f -print0 | xargs -0 du --block-size=1 -c | awk 'END { print $1 }')
- if my_print_defaults -c $WSREP_SST_OPT_CONF xtrabackup | grep -q -- "--compress";then
+ if $my_print_defaults xtrabackup | grep -q -- "--compress";then
# QuickLZ has around 50% compression ratio
# When compression/compaction used, the progress is only an approximate.
payload=$(( payload*1/2 ))
@@ -385,8 +385,8 @@ check_extra()
{
local use_socket=1
if [[ $uextra -eq 1 ]];then
- if my_print_defaults -c $WSREP_SST_OPT_CONF mysqld | tr '_' '-' | grep -- "--thread-handling=" | grep -q 'pool-of-threads';then
- local eport=$(my_print_defaults -c $WSREP_SST_OPT_CONF mysqld | tr '_' '-' | grep -- "--extra-port=" | cut -d= -f2)
+ if $my_print_defaults --mysqld | tr '_' '-' | grep -- "--thread-handling=" | grep -q 'pool-of-threads';then
+ local eport=$($my_print_defaults --mysqld | tr '_' '-' | grep -- "--extra-port=" | cut -d= -f2)
if [[ -n $eport ]];then
# Xtrabackup works only locally.
# Hence, setting host to 127.0.0.1 unconditionally.
@@ -424,8 +424,8 @@ get_stream
get_transfer
INNOEXTRA=""
-INNOAPPLY="${INNOBACKUPEX_BIN} --defaults-file=${WSREP_SST_OPT_CONF} --apply-log \$rebuildcmd \${DATA} &>\${DATA}/innobackup.prepare.log"
-INNOBACKUP="${INNOBACKUPEX_BIN} --defaults-file=${WSREP_SST_OPT_CONF} \$INNOEXTRA --galera-info --stream=\$sfmt \${TMPDIR} 2>\${DATA}/innobackup.backup.log"
+INNOAPPLY="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} --apply-log \$rebuildcmd \${DATA} &>\${DATA}/innobackup.prepare.log"
+INNOBACKUP="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} \$INNOEXTRA --galera-info --stream=\$sfmt \${TMPDIR} 2>\${DATA}/innobackup.backup.log"
if [ "$WSREP_SST_OPT_ROLE" = "donor" ]
then
@@ -528,7 +528,7 @@ then
if [[ $incremental -eq 1 ]];then
wsrep_log_info "Incremental SST enabled"
- #lsn=$(/pxc/bin/mysqld --defaults-file=$WSREP_SST_OPT_CONF --basedir=/pxc --wsrep-recover 2>&1 | grep -o 'log sequence number .*' | cut -d " " -f 4 | head -1)
+ #lsn=$(/pxc/bin/mysqld $WSREP_SST_OPT_CONF --basedir=/pxc --wsrep-recover 2>&1 | grep -o 'log sequence number .*' | cut -d " " -f 4 | head -1)
lsn=$(grep to_lsn xtrabackup_checkpoints | cut -d= -f2 | tr -d ' ')
wsrep_log_info "Recovered LSN: $lsn"
fi
@@ -681,7 +681,7 @@ then
if [[ $incremental -eq 1 ]];then
# Added --ibbackup=xtrabackup_55 because it fails otherwise citing connection issues.
- INNOAPPLY="${INNOBACKUPEX_BIN} --defaults-file=${WSREP_SST_OPT_CONF} \
+ INNOAPPLY="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} \
--ibbackup=xtrabackup_55 --apply-log $rebuildcmd --redo-only $BDATA --incremental-dir=${DATA} &>>${BDATA}/innobackup.prepare.log"
fi
diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc
index c122d88f7cc..17943308c37 100644
--- a/sql/wsrep_sst.cc
+++ b/sql/wsrep_sst.cc
@@ -29,7 +29,9 @@
#include <cstdio>
#include <cstdlib>
-extern const char wsrep_defaults_file[];
+char wsrep_defaults_file[FN_REFLEN * 2 + 10 +
+ sizeof(WSREP_SST_OPT_CONF) +
+ sizeof(WSREP_SST_OPT_EXTRA_CONF)] = {0};
const char* wsrep_sst_method = WSREP_SST_DEFAULT;
const char* wsrep_sst_receive_address = WSREP_SST_ADDRESS_AUTO;
@@ -59,6 +61,24 @@ bool wsrep_sst_method_update (sys_var *self, THD* thd, enum_var_type type)
return 0;
}
+
+static void make_wsrep_defaults_file()
+{
+ if (!wsrep_defaults_file[0])
+ {
+ char *ptr= wsrep_defaults_file;
+ char *end= ptr + sizeof(wsrep_defaults_file);
+ if (my_defaults_file)
+ ptr= strxnmov(ptr, end - ptr,
+ WSREP_SST_OPT_CONF, " '", my_defaults_file, "' ", NULL);
+
+ if (my_defaults_extra_file)
+ ptr= strxnmov(ptr, end - ptr,
+ WSREP_SST_OPT_EXTRA_CONF, " '", my_defaults_extra_file, "' ", NULL);
+ }
+}
+
+
// TODO: Improve address verification.
static bool sst_receive_address_check (const char* str)
{
@@ -455,6 +475,7 @@ static ssize_t sst_prepare_other (const char* method,
}
if (strlen(binlog_opt_val)) binlog_opt= WSREP_SST_OPT_BINLOG;
+ make_wsrep_defaults_file();
ret= snprintf (cmd_str, cmd_len,
"wsrep_sst_%s "
@@ -462,7 +483,7 @@ static ssize_t sst_prepare_other (const char* method,
WSREP_SST_OPT_ADDR" '%s' "
WSREP_SST_OPT_AUTH" '%s' "
WSREP_SST_OPT_DATA" '%s' "
- WSREP_SST_OPT_CONF" '%s' "
+ " %s "
WSREP_SST_OPT_PARENT" '%d'"
" %s '%s' ",
method, addr_in, (sst_auth_real) ? sst_auth_real : "",
@@ -754,6 +775,8 @@ static int sst_donate_mysqldump (const char* addr,
if (!bypass && wsrep_sst_donor_rejects_queries) sst_reject_queries(TRUE);
+ make_wsrep_defaults_file();
+
snprintf (cmd_str, cmd_len,
"wsrep_sst_mysqldump "
WSREP_SST_OPT_USER" '%s' "
@@ -762,7 +785,7 @@ static int sst_donate_mysqldump (const char* addr,
WSREP_SST_OPT_PORT" '%s' "
WSREP_SST_OPT_LPORT" '%u' "
WSREP_SST_OPT_SOCKET" '%s' "
- WSREP_SST_OPT_CONF" '%s' "
+ " %s "
WSREP_SST_OPT_GTID" '%s:%lld'"
"%s",
user, pswd, host, port, mysqld_port, mysqld_unix_port,
@@ -1027,6 +1050,8 @@ static int sst_donate_other (const char* method,
}
if (strlen(binlog_opt_val)) binlog_opt= WSREP_SST_OPT_BINLOG;
+ make_wsrep_defaults_file();
+
ret= snprintf (cmd_str, cmd_len,
"wsrep_sst_%s "
WSREP_SST_OPT_ROLE" 'donor' "
@@ -1034,7 +1059,7 @@ static int sst_donate_other (const char* method,
WSREP_SST_OPT_AUTH" '%s' "
WSREP_SST_OPT_SOCKET" '%s' "
WSREP_SST_OPT_DATA" '%s' "
- WSREP_SST_OPT_CONF" '%s' "
+ " %s "
" %s '%s' "
WSREP_SST_OPT_GTID" '%s:%lld'"
"%s",
diff --git a/sql/wsrep_sst.h b/sql/wsrep_sst.h
index be1dfcfa582..2a6ab406297 100644
--- a/sql/wsrep_sst.h
+++ b/sql/wsrep_sst.h
@@ -27,6 +27,7 @@
#define WSREP_SST_OPT_AUTH "--auth"
#define WSREP_SST_OPT_DATA "--datadir"
#define WSREP_SST_OPT_CONF "--defaults-file"
+#define WSREP_SST_OPT_EXTRA_CONF "--defaults-extra-file"
#define WSREP_SST_OPT_PARENT "--parent"
#define WSREP_SST_OPT_BINLOG "--binlog"