Commit b44b9f71 authored by Jan Lindström's avatar Jan Lindström

MDEV-15436: If log_bin and log_bin_index is different SST with rsync fails.

Problem was that in SST log_bin_index name and directory was not
handled and passed to rsync SST script.

wsrep_sst_common.sh
	Read binlog index dirname and filename if --binlog-index
	parameter is provided. Read binlog filenames from that file
	from donor and write transfered binlog filenames to that
	file in joiner.

mysqld.cc, mysqld.h
	Moved opt_binlog_index_name from static to global and added
	it to extern.

wsrep_sst.cc

generate_binlog_index_opt_val
	New function to generate binlog index name if opt_binlog_index_name is
	given on configuration.

sst_prepare_other
	Add binlog index configuration to SST command.

wsrep_sst.h
	Add new SST parameter --binlog-index

Add test case.
parent 4caf3e08
This diff is collapsed.
!include ../galera_2nodes.cnf
[mysqld]
wsrep_sst_method=rsync
[mysqld.1]
wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true'
log_bin=@ENV.MYSQL_TEST_DIR/var/server1_binlog
log_bin_index=@ENV.MYSQL_TEST_DIR/var/tmp/server1_binlog_index.index
[mysqld.2]
wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true'
log_bin=@ENV.MYSQL_TEST_DIR/var/server2_binlog
log_bin_index=@ENV.MYSQL_TEST_DIR/var/tmp/server2_binlog_index.index
--source include/galera_cluster.inc
--let $node_1=node_1
--let $node_2=node_2
--source include/auto_increment_offset_save.inc
--source suite/galera/include/galera_st_shutdown_slave.inc
--source suite/galera/include/galera_st_clean_slave.inc
--source suite/galera/include/galera_st_kill_slave.inc
--source suite/galera/include/galera_st_kill_slave_ddl.inc
--source include/auto_increment_offset_restore.inc
......@@ -20,6 +20,7 @@ set -u
WSREP_SST_OPT_BYPASS=0
WSREP_SST_OPT_BINLOG=""
WSREP_SST_OPT_BINLOG_INDEX=""
WSREP_SST_OPT_DATA=""
WSREP_SST_OPT_AUTH=${WSREP_SST_OPT_AUTH:-}
WSREP_SST_OPT_USER=${WSREP_SST_OPT_USER:-}
......@@ -120,6 +121,10 @@ case "$1" in
WSREP_SST_OPT_BINLOG="$2"
shift
;;
'--binlog-index')
WSREP_SST_OPT_BINLOG_INDEX="$2"
shift
;;
'--gtid-domain-id')
readonly WSREP_SST_OPT_GTID_DOMAIN_ID="$2"
shift
......@@ -133,6 +138,7 @@ shift
done
readonly WSREP_SST_OPT_BYPASS
readonly WSREP_SST_OPT_BINLOG
readonly WSREP_SST_OPT_BINLOG_INDEX
if [ -n "${WSREP_SST_OPT_ADDR_PORT:-}" ]; then
if [ -n "${WSREP_SST_OPT_PORT:-}" ]; then
......
......@@ -105,6 +105,14 @@ if ! [ -z $WSREP_SST_OPT_BINLOG ]
then
BINLOG_DIRNAME=$(dirname $WSREP_SST_OPT_BINLOG)
BINLOG_FILENAME=$(basename $WSREP_SST_OPT_BINLOG)
BINLOG_INDEX_DIRNAME=$(dirname $WSREP_SST_OPT_BINLOG)
BINLOG_INDEX_FILENAME=$(basename $WSREP_SST_OPT_BINLOG)
fi
if ! [ -z $WSREP_SST_OPT_BINLOG_INDEX ]
then
BINLOG_INDEX_DIRNAME=$(dirname $WSREP_SST_OPT_BINLOG_INDEX)
BINLOG_INDEX_FILENAME=$(basename $WSREP_SST_OPT_BINLOG_INDEX)
fi
WSREP_LOG_DIR=${WSREP_LOG_DIR:-""}
......@@ -210,19 +218,29 @@ EOF
if ! [ -z $WSREP_SST_OPT_BINLOG ]
then
# Prepare binlog files
pushd $BINLOG_DIRNAME &> /dev/null
binlog_files_full=$(tail -n $BINLOG_N_FILES ${BINLOG_FILENAME}.index)
OLD_PWD="$(pwd)"
cd $BINLOG_DIRNAME
if ! [ -z $WSREP_SST_OPT_BINLOG_INDEX ]
binlog_files_full=$(tail -n $BINLOG_N_FILES ${BINLOG_FILENAME}.index)
then
cd $BINLOG_INDEX_DIRNAME
binlog_files_full=$(tail -n $BINLOG_N_FILES ${BINLOG_INDEX_FILENAME}.index)
fi
cd $BINLOG_DIRNAME
binlog_files=""
for ii in $binlog_files_full
do
binlog_files="$binlog_files $(basename $ii)"
done
if ! [ -z "$binlog_files" ]
then
wsrep_log_info "Preparing binlog files for transfer:"
tar -cvf $BINLOG_TAR_FILE $binlog_files >&2
fi
popd &> /dev/null
cd "$OLD_PWD"
fi
# first, the normal directories, so that we can detect incompatible protocol
......@@ -276,7 +294,8 @@ EOF
fi
# then, we parallelize the transfer of database directories, use . so that pathconcatenation works
pushd "$WSREP_SST_OPT_DATA" >/dev/null
OLD_PWD="$(pwd)"
cd $WSREP_SST_OPT_DATA
count=1
[ "$OS" == "Linux" ] && count=$(grep -c processor /proc/cpuinfo)
......@@ -290,7 +309,7 @@ EOF
$WHOLE_FILE_OPT --exclude '*/ib_logfile*' "$WSREP_SST_OPT_DATA"/{}/ \
rsync://$WSREP_SST_OPT_ADDR/{} >&2 || RC=$?
popd >/dev/null
cd "$OLD_PWD"
if [ $RC -ne 0 ]; then
wsrep_log_error "find/rsync returned code $RC:"
......@@ -420,7 +439,9 @@ EOF
if ! [ -z $WSREP_SST_OPT_BINLOG ]
then
pushd $BINLOG_DIRNAME &> /dev/null
OLD_PWD="$(pwd)"
cd $BINLOG_DIRNAME
if [ -f $BINLOG_TAR_FILE ]
then
# Clean up old binlog files first
......@@ -429,10 +450,14 @@ EOF
tar -xvf $BINLOG_TAR_FILE >&2
for ii in $(ls -1 ${BINLOG_FILENAME}.*)
do
echo ${BINLOG_DIRNAME}/${ii} >> ${BINLOG_FILENAME}.index
if ! [ -z $WSREP_SST_OPT_BINLOG_INDEX ]
echo ${BINLOG_DIRNAME}/${ii} >> ${BINLOG_FILENAME}.index
then
echo ${BINLOG_DIRNAME}/${ii} >> ${BINLOG_INDEX_DIRNAME}/${BINLOG_INDEX_FILENAME}.index
fi
done
fi
popd &> /dev/null
cd "$OLD_PWD"
fi
if [ -r "$MAGIC_FILE" ]
then
......
......@@ -754,6 +754,7 @@ char *master_info_file;
char *relay_log_info_file, *report_user, *report_password, *report_host;
char *opt_relay_logname = 0, *opt_relaylog_index_name=0;
char *opt_logname, *opt_slow_logname, *opt_bin_logname;
char *opt_binlog_index_name=0;
/* Static variables */
......@@ -763,7 +764,6 @@ my_bool opt_expect_abort= 0, opt_bootstrap= 0;
static my_bool opt_myisam_log;
static int cleanup_done;
static ulong opt_specialflag;
static char *opt_binlog_index_name;
char *mysql_home_ptr, *pidfile_name_ptr;
/** Initial command line arguments (count), after load_defaults().*/
static int defaults_argc;
......
......@@ -165,6 +165,7 @@ extern uint protocol_version, mysqld_port, dropping_tables;
extern ulong delay_key_write_options;
extern char *opt_logname, *opt_slow_logname, *opt_bin_logname,
*opt_relay_logname;
extern char *opt_binlog_index_name;
extern char *opt_backup_history_logname, *opt_backup_progress_logname,
*opt_backup_settings_name;
extern const char *log_output_str;
......
......@@ -408,6 +408,22 @@ static int generate_binlog_opt_val(char** ret)
return 0;
}
static int generate_binlog_index_opt_val(char** ret)
{
DBUG_ASSERT(ret);
*ret= NULL;
if (opt_binlog_index_name) {
*ret= strcmp(opt_binlog_index_name, "0") ?
my_strdup(opt_binlog_index_name, MYF(0)) : my_strdup("", MYF(0));
}
else
{
*ret= my_strdup("", MYF(0));
}
if (!*ret) return -ENOMEM;
return 0;
}
static void* sst_joiner_thread (void* a)
{
sst_thread_arg* arg= (sst_thread_arg*) a;
......@@ -595,7 +611,9 @@ static ssize_t sst_prepare_other (const char* method,
}
const char* binlog_opt= "";
const char* binlog_index_opt= "";
char* binlog_opt_val= NULL;
char* binlog_index_opt_val= NULL;
int ret;
if ((ret= generate_binlog_opt_val(&binlog_opt_val)))
......@@ -604,7 +622,15 @@ static ssize_t sst_prepare_other (const char* method,
ret);
return ret;
}
if ((ret= generate_binlog_index_opt_val(&binlog_index_opt_val)))
{
WSREP_ERROR("sst_prepare_other(): generate_binlog_index_opt_val() failed %d",
ret);
}
if (strlen(binlog_opt_val)) binlog_opt= WSREP_SST_OPT_BINLOG;
if (strlen(binlog_index_opt_val)) binlog_index_opt= WSREP_SST_OPT_BINLOG_INDEX;
make_wsrep_defaults_file();
......@@ -615,11 +641,14 @@ static ssize_t sst_prepare_other (const char* method,
WSREP_SST_OPT_DATA " '%s' "
" %s "
WSREP_SST_OPT_PARENT " '%d'"
" %s '%s' ",
" %s '%s'"
" %s '%s'",
method, addr_in, mysql_real_data_home,
wsrep_defaults_file,
(int)getpid(), binlog_opt, binlog_opt_val);
(int)getpid(), binlog_opt, binlog_opt_val,
binlog_index_opt, binlog_index_opt_val);
my_free(binlog_opt_val);
my_free(binlog_index_opt_val);
if (ret < 0 || ret >= cmd_len)
{
......
......@@ -31,6 +31,7 @@
#define WSREP_SST_OPT_CONF_EXTRA "--defaults-extra-file"
#define WSREP_SST_OPT_PARENT "--parent"
#define WSREP_SST_OPT_BINLOG "--binlog"
#define WSREP_SST_OPT_BINLOG_INDEX "--binlog-index"
// mysqldump-specific options
#define WSREP_SST_OPT_USER "--user"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment