Commit 99df0fba authored by Nirbhay Choubey's avatar Nirbhay Choubey

bzr merge -r3968..3984 codership/5.5 (non-Innodb changes only).

parent 8a6f4e19
...@@ -20,6 +20,7 @@ set -u ...@@ -20,6 +20,7 @@ set -u
WSREP_SST_OPT_BYPASS=0 WSREP_SST_OPT_BYPASS=0
WSREP_SST_OPT_DATA="" WSREP_SST_OPT_DATA=""
WSREP_SST_OPT_AUTH=""
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case "$1" in case "$1" in
...@@ -55,7 +56,7 @@ case "$1" in ...@@ -55,7 +56,7 @@ case "$1" in
shift shift
;; ;;
'--password') '--password')
readonly WSREP_SST_OPT_PSWD="$2" WSREP_SST_OPT_PSWD="$2"
shift shift
;; ;;
'--port') '--port')
...@@ -71,7 +72,7 @@ case "$1" in ...@@ -71,7 +72,7 @@ case "$1" in
shift shift
;; ;;
'--user') '--user')
readonly WSREP_SST_OPT_USER="$2" WSREP_SST_OPT_USER="$2"
shift shift
;; ;;
'--gtid') '--gtid')
...@@ -89,7 +90,7 @@ readonly WSREP_SST_OPT_BYPASS ...@@ -89,7 +90,7 @@ readonly WSREP_SST_OPT_BYPASS
# For Bug:1200727 # For Bug:1200727
if my_print_defaults -c $WSREP_SST_OPT_CONF sst | grep -q "wsrep_sst_auth";then if my_print_defaults -c $WSREP_SST_OPT_CONF sst | grep -q "wsrep_sst_auth";then
if [ -z $WSREP_SST_OPT_AUTH -o $WSREP_SST_OPT_AUTH = "(null)" ];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 -c $WSREP_SST_OPT_CONF sst | grep -- "--wsrep_sst_auth" | cut -d= -f2)
fi fi
fi fi
...@@ -124,4 +125,3 @@ wsrep_cleanup_progress_file() ...@@ -124,4 +125,3 @@ wsrep_cleanup_progress_file()
{ {
[ -n "$SST_PROGRESS_FILE" ] && rm -f "$SST_PROGRESS_FILE" 2>/dev/null [ -n "$SST_PROGRESS_FILE" ] && rm -f "$SST_PROGRESS_FILE" 2>/dev/null
} }
#!/bin/sh -e #!/bin/bash -e
# Copyright (C) 2009 Codership Oy # Copyright (C) 2009 Codership Oy
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
...@@ -65,6 +65,11 @@ then ...@@ -65,6 +65,11 @@ then
exit $EINVAL exit $EINVAL
fi fi
# For Bug:1293798
if [ -z "$WSREP_SST_OPT_PSWD" -a -n "$WSREP_SST_OPT_AUTH" ]; then
WSREP_SST_OPT_USER=$(echo $WSREP_SST_OPT_AUTH | cut -d: -f1)
WSREP_SST_OPT_PSWD=$(echo $WSREP_SST_OPT_AUTH | cut -d: -f2)
fi
AUTH="-u$WSREP_SST_OPT_USER" AUTH="-u$WSREP_SST_OPT_USER"
if test -n "$WSREP_SST_OPT_PSWD"; then AUTH="$AUTH -p$WSREP_SST_OPT_PSWD"; fi if test -n "$WSREP_SST_OPT_PSWD"; then AUTH="$AUTH -p$WSREP_SST_OPT_PSWD"; fi
...@@ -123,4 +128,5 @@ else ...@@ -123,4 +128,5 @@ else
wsrep_log_info "Bypassing state dump." wsrep_log_info "Bypassing state dump."
echo $SET_START_POSITION | $MYSQL echo $SET_START_POSITION | $MYSQL
fi fi
wsrep_cleanup_progress_file
#
...@@ -25,6 +25,9 @@ OS=$(uname) ...@@ -25,6 +25,9 @@ OS=$(uname)
. $(dirname $0)/wsrep_sst_common . $(dirname $0)/wsrep_sst_common
# Setting the path for lsof on CentOS
export PATH="/usr/sbin:/sbin:$PATH"
cleanup_joiner() cleanup_joiner()
{ {
wsrep_log_info "Joiner cleanup." wsrep_log_info "Joiner cleanup."
...@@ -49,19 +52,21 @@ check_pid() ...@@ -49,19 +52,21 @@ check_pid()
check_pid_and_port() check_pid_and_port()
{ {
local pid_file=$1 local pid_file=$1
local rsync_pid=$(cat $pid_file) local rsync_pid=$2
local rsync_port=$2 local rsync_port=$3
if [ "$OS" == "Darwin" -o "$OS" == "FreeBSD" ]; then local port_info=$(lsof -i :$rsync_port -Pn 2>/dev/null | \
# no netstat --program(-p) option in Darwin and FreeBSD grep "(LISTEN)")
check_pid $pid_file && \ local is_rsync=$(echo $port_info | \
lsof -i -Pn 2>/dev/null | \ grep -w '^rsync[[:space:]]\+'"$rsync_pid" 2>/dev/null)
grep "(LISTEN)" | grep ":$rsync_port" | grep -w '^rsync[[:space:]]\+'"$rsync_pid" >/dev/null
else if [ -n "$port_info" -a -z "$is_rsync" ]; then
check_pid $pid_file && \ wsrep_log_error "rsync daemon port '$rsync_port' has been taken"
netstat -lnpt 2>/dev/null | \ exit 16 # EBUSY
grep LISTEN | grep \:$rsync_port | grep $rsync_pid/rsync >/dev/null
fi fi
check_pid $pid_file && \
[ -n "$port_info" ] && [ -n "$is_rsync" ] && \
[ $(cat $pid_file) -eq $rsync_pid ]
} }
MAGIC_FILE="$WSREP_SST_OPT_DATA/rsync_sst_complete" MAGIC_FILE="$WSREP_SST_OPT_DATA/rsync_sst_complete"
...@@ -234,9 +239,10 @@ EOF ...@@ -234,9 +239,10 @@ EOF
# rm -rf "$DATA"/ib_logfile* # we don't want old logs around # rm -rf "$DATA"/ib_logfile* # we don't want old logs around
# listen at all interfaces (for firewalled setups) # listen at all interfaces (for firewalled setups)
rsync --daemon --port $RSYNC_PORT --config "$RSYNC_CONF" rsync --daemon --no-detach --port $RSYNC_PORT --config "$RSYNC_CONF" &
RSYNC_REAL_PID=$!
until check_pid_and_port $RSYNC_PID $RSYNC_PORT until check_pid_and_port $RSYNC_PID $RSYNC_REAL_PID $RSYNC_PORT
do do
sleep 0.2 sleep 0.2
done done
......
...@@ -4370,6 +4370,9 @@ pthread_handler_t handle_slave_sql(void *arg) ...@@ -4370,6 +4370,9 @@ pthread_handler_t handle_slave_sql(void *arg)
my_off_t saved_skip= 0; my_off_t saved_skip= 0;
Master_info *mi= ((Master_info*)arg); Master_info *mi= ((Master_info*)arg);
Relay_log_info* rli = &mi->rli; Relay_log_info* rli = &mi->rli;
#ifdef WITH_WSREP
my_bool wsrep_node_dropped= FALSE;
#endif /* WITH_WSREP */
const char *errmsg; const char *errmsg;
rpl_group_info *serial_rgi; rpl_group_info *serial_rgi;
rpl_sql_thread_info sql_info(mi->rpl_filter); rpl_sql_thread_info sql_info(mi->rpl_filter);
...@@ -4377,6 +4380,9 @@ pthread_handler_t handle_slave_sql(void *arg) ...@@ -4377,6 +4380,9 @@ pthread_handler_t handle_slave_sql(void *arg)
// needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff // needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
my_thread_init(); my_thread_init();
DBUG_ENTER("handle_slave_sql"); DBUG_ENTER("handle_slave_sql");
#ifdef WITH_WSREP
wsrep_restart_point:
#endif /* WITH_WSREP */
LINT_INIT(saved_master_log_pos); LINT_INIT(saved_master_log_pos);
LINT_INIT(saved_log_pos); LINT_INIT(saved_log_pos);
...@@ -4617,7 +4623,15 @@ log '%s' at position %s, relay log '%s' position: %s%s", RPL_LOG_NAME, ...@@ -4617,7 +4623,15 @@ log '%s' at position %s, relay log '%s' position: %s%s", RPL_LOG_NAME,
DBUG_PRINT("info", ("exec_relay_log_event() failed")); DBUG_PRINT("info", ("exec_relay_log_event() failed"));
// do not scare the user if SQL thread was simply killed or stopped // do not scare the user if SQL thread was simply killed or stopped
if (!sql_slave_killed(serial_rgi)) if (!sql_slave_killed(serial_rgi))
{
slave_output_error_info(rli, thd); slave_output_error_info(rli, thd);
#ifdef WITH_WSREP
if (WSREP_ON && last_errno == ER_UNKNOWN_COM_ERROR)
{
wsrep_node_dropped= TRUE;
}
#endif /* WITH_WSREP */
}
goto err; goto err;
} }
} }
...@@ -4702,30 +4716,35 @@ err_during_init: ...@@ -4702,30 +4716,35 @@ err_during_init:
delete serial_rgi; delete serial_rgi;
delete thd; delete thd;
mysql_mutex_unlock(&LOCK_thread_count); mysql_mutex_unlock(&LOCK_thread_count);
/*
Note: the order of the broadcast and unlock calls below (first broadcast, then unlock)
is important. Otherwise a killer_thread can execute between the calls and
delete the mi structure leading to a crash! (see BUG#25306 for details)
*/
mysql_cond_broadcast(&rli->stop_cond);
DBUG_EXECUTE_IF("simulate_slave_delay_at_terminate_bug38694", sleep(5););
mysql_mutex_unlock(&rli->run_lock); // tell the world we are done
#ifdef WITH_WSREP #ifdef WITH_WSREP
/* if slave stopped due to node going non primary, we set global flag to /* if slave stopped due to node going non primary, we set global flag to
trigger automatic restart of slave when node joins back to cluster trigger automatic restart of slave when node joins back to cluster
*/ */
if (WSREP_ON && !wsrep_ready) if (wsrep_node_dropped && wsrep_restart_slave)
{ {
WSREP_INFO("Slave thread stopped because node dropped from cluster"); if (wsrep_ready)
if (wsrep_restart_slave)
{ {
WSREP_INFO("Slave error due to node temporarily non-primary"
"SQL slave will continue");
wsrep_node_dropped= FALSE;
mysql_mutex_unlock(&rli->run_lock);
goto wsrep_restart_point;
} else {
WSREP_INFO("Slave error due to node going non-primary");
WSREP_INFO("wsrep_restart_slave was set and therefore slave will be " WSREP_INFO("wsrep_restart_slave was set and therefore slave will be "
"automatically restarted when node joins back to cluster"); "automatically restarted when node joins back to cluster");
wsrep_restart_slave_activated= TRUE; wsrep_restart_slave_activated= TRUE;
} }
} }
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
/*
Note: the order of the broadcast and unlock calls below (first broadcast, then unlock)
is important. Otherwise a killer_thread can execute between the calls and
delete the mi structure leading to a crash! (see BUG#25306 for details)
*/
mysql_cond_broadcast(&rli->stop_cond);
DBUG_EXECUTE_IF("simulate_slave_delay_at_terminate_bug38694", sleep(5););
mysql_mutex_unlock(&rli->run_lock); // tell the world we are done
DBUG_LEAVE; // Must match DBUG_ENTER() DBUG_LEAVE; // Must match DBUG_ENTER()
my_thread_end(); my_thread_end();
......
...@@ -4598,6 +4598,7 @@ restart: ...@@ -4598,6 +4598,7 @@ restart:
thd->lex->sql_command== SQLCOM_LOAD || thd->lex->sql_command== SQLCOM_LOAD ||
thd->lex->sql_command== SQLCOM_DELETE) && thd->lex->sql_command== SQLCOM_DELETE) &&
wsrep_replicate_myisam && wsrep_replicate_myisam &&
(*start) &&
(*start)->table && (*start)->table->file->ht->db_type == DB_TYPE_MYISAM) (*start)->table && (*start)->table->file->ht->db_type == DB_TYPE_MYISAM)
{ {
WSREP_TO_ISOLATION_BEGIN(NULL, NULL, (*start)); WSREP_TO_ISOLATION_BEGIN(NULL, NULL, (*start));
......
...@@ -513,11 +513,17 @@ wsrep_run_wsrep_commit(THD *thd, handlerton *hton, bool all) ...@@ -513,11 +513,17 @@ wsrep_run_wsrep_commit(THD *thd, handlerton *hton, bool all)
DBUG_RETURN(WSREP_TRX_CERT_FAIL); DBUG_RETURN(WSREP_TRX_CERT_FAIL);
case WSREP_SIZE_EXCEEDED:
WSREP_ERROR("transaction size exceeded");
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
DBUG_RETURN(WSREP_TRX_SIZE_EXCEEDED);
case WSREP_CONN_FAIL: case WSREP_CONN_FAIL:
WSREP_ERROR("connection failure"); WSREP_ERROR("connection failure");
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
DBUG_RETURN(WSREP_TRX_ERROR); DBUG_RETURN(WSREP_TRX_ERROR);
default: default:
WSREP_ERROR("unknown connection failure"); WSREP_ERROR("unknown connection failure");
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
DBUG_RETURN(WSREP_TRX_ERROR); DBUG_RETURN(WSREP_TRX_ERROR);
} }
......
...@@ -433,9 +433,22 @@ static void wsrep_synced_cb(void* app_ctx) ...@@ -433,9 +433,22 @@ static void wsrep_synced_cb(void* app_ctx)
} }
if (wsrep_restart_slave_activated) if (wsrep_restart_slave_activated)
{ {
int rcode;
WSREP_INFO("MySQL slave restart"); WSREP_INFO("MySQL slave restart");
wsrep_restart_slave_activated= FALSE; wsrep_restart_slave_activated= FALSE;
init_slave();
mysql_mutex_lock(&LOCK_active_mi);
if ((rcode = start_slave_threads(1 /* need mutex */,
0 /* no wait for start*/,
active_mi,
master_info_file,
relay_log_info_file,
SLAVE_SQL)))
{
WSREP_WARN("Failed to create slave threads: %d", rcode);
}
mysql_mutex_unlock(&LOCK_active_mi);
} }
} }
...@@ -526,6 +539,7 @@ int wsrep_init() ...@@ -526,6 +539,7 @@ int wsrep_init()
{ {
DBUG_PRINT("wsrep",("wsrep::init() failed: %d", rcode)); DBUG_PRINT("wsrep",("wsrep::init() failed: %d", rcode));
WSREP_ERROR("wsrep::init() failed: %d, must shutdown", rcode); WSREP_ERROR("wsrep::init() failed: %d, must shutdown", rcode);
wsrep->free(wsrep);
free(wsrep); free(wsrep);
wsrep = NULL; wsrep = NULL;
} }
...@@ -670,6 +684,7 @@ int wsrep_init() ...@@ -670,6 +684,7 @@ int wsrep_init()
{ {
DBUG_PRINT("wsrep",("wsrep::init() failed: %d", rcode)); DBUG_PRINT("wsrep",("wsrep::init() failed: %d", rcode));
WSREP_ERROR("wsrep::init() failed: %d, must shutdown", rcode); WSREP_ERROR("wsrep::init() failed: %d, must shutdown", rcode);
wsrep->free(wsrep);
free(wsrep); free(wsrep);
wsrep = NULL; wsrep = NULL;
} else { } else {
......
...@@ -75,6 +75,8 @@ void wsrep_notify_status (wsrep_member_status_t status, ...@@ -75,6 +75,8 @@ void wsrep_notify_status (wsrep_member_status_t status,
cmd_off += snprintf (cmd_ptr + cmd_off, cmd_len - cmd_off, cmd_off += snprintf (cmd_ptr + cmd_off, cmd_len - cmd_off,
" --index %d", view->my_idx); " --index %d", view->my_idx);
if (view->memb_num)
{
cmd_off += snprintf (cmd_ptr + cmd_off, cmd_len - cmd_off, " --members"); cmd_off += snprintf (cmd_ptr + cmd_off, cmd_len - cmd_off, " --members");
for (int i = 0; i < view->memb_num; i++) for (int i = 0; i < view->memb_num; i++)
...@@ -86,6 +88,7 @@ void wsrep_notify_status (wsrep_member_status_t status, ...@@ -86,6 +88,7 @@ void wsrep_notify_status (wsrep_member_status_t status,
view->members[i].incoming); view->members[i].incoming);
} }
} }
}
if (cmd_off == cmd_len) if (cmd_off == cmd_len)
{ {
......
...@@ -763,9 +763,11 @@ static int sst_donate_mysqldump (const char* addr, ...@@ -763,9 +763,11 @@ static int sst_donate_mysqldump (const char* addr,
WSREP_SST_OPT_PORT" '%s' " WSREP_SST_OPT_PORT" '%s' "
WSREP_SST_OPT_LPORT" '%u' " WSREP_SST_OPT_LPORT" '%u' "
WSREP_SST_OPT_SOCKET" '%s' " WSREP_SST_OPT_SOCKET" '%s' "
WSREP_SST_OPT_CONF" '%s' "
WSREP_SST_OPT_GTID" '%s:%lld'" WSREP_SST_OPT_GTID" '%s:%lld'"
"%s", "%s",
user, pswd, host, port, mysqld_port, mysqld_unix_port, uuid_str, user, pswd, host, port, mysqld_port, mysqld_unix_port,
wsrep_defaults_file, uuid_str,
(long long)seqno, bypass ? " "WSREP_SST_OPT_BYPASS : ""); (long long)seqno, bypass ? " "WSREP_SST_OPT_BYPASS : "");
WSREP_DEBUG("Running: '%s'", cmd_str); WSREP_DEBUG("Running: '%s'", cmd_str);
......
...@@ -20,13 +20,11 @@ ...@@ -20,13 +20,11 @@
#include <errno.h> #include <errno.h>
#include <stdbool.h> #include <stdbool.h>
#include <string.h>
/*! Dummy backend context. */ /*! Dummy backend context. */
typedef struct wsrep_dummy typedef struct wsrep_dummy
{ {
wsrep_log_cb_t log_fn; wsrep_log_cb_t log_fn;
char* options;
} wsrep_dummy_t; } wsrep_dummy_t;
/* Get pointer to wsrep_dummy context from wsrep_t pointer */ /* Get pointer to wsrep_dummy context from wsrep_t pointer */
...@@ -44,10 +42,6 @@ typedef struct wsrep_dummy ...@@ -44,10 +42,6 @@ typedef struct wsrep_dummy
static void dummy_free(wsrep_t *w) static void dummy_free(wsrep_t *w)
{ {
WSREP_DBUG_ENTER(w); WSREP_DBUG_ENTER(w);
if (WSREP_DUMMY(w)->options)
{
free(WSREP_DUMMY(w)->options);
}
free(w->ctx); free(w->ctx);
w->ctx = NULL; w->ctx = NULL;
} }
...@@ -55,15 +49,8 @@ static void dummy_free(wsrep_t *w) ...@@ -55,15 +49,8 @@ static void dummy_free(wsrep_t *w)
static wsrep_status_t dummy_init (wsrep_t* w, static wsrep_status_t dummy_init (wsrep_t* w,
const struct wsrep_init_args* args) const struct wsrep_init_args* args)
{ {
WSREP_DBUG_ENTER(w);
WSREP_DUMMY(w)->log_fn = args->logger_cb; WSREP_DUMMY(w)->log_fn = args->logger_cb;
if (args->options) WSREP_DBUG_ENTER(w);
{
char* options = malloc(strlen(args->options) + 1);
if (options == NULL) return WSREP_WARNING;
strcpy(options, args->options);
WSREP_DUMMY(w)->options = options;
}
return WSREP_OK; return WSREP_OK;
} }
...@@ -74,41 +61,16 @@ static uint64_t dummy_capabilities (wsrep_t* w __attribute__((unused))) ...@@ -74,41 +61,16 @@ static uint64_t dummy_capabilities (wsrep_t* w __attribute__((unused)))
static wsrep_status_t dummy_options_set( static wsrep_status_t dummy_options_set(
wsrep_t* w, wsrep_t* w,
const char* conf) const char* conf __attribute__((unused)))
{ {
char* options = NULL; WSREP_DBUG_ENTER(w);
WSREP_DBUG_ENTER(w);
// concatenate config string with ';'
options = WSREP_DUMMY(w)->options;
if (options == NULL)
{
options = malloc(strlen(conf) + 1);
if (options == NULL)
{
return WSREP_WARNING;
}
strcpy(options, conf);
} else {
int opt_len = strlen(options);
char* p = realloc(options,
opt_len + 1 + // ';'
strlen(conf) + 1); // \0
if (p == NULL)
{
return WSREP_WARNING;
}
p[opt_len] = ';';
strcpy(p + opt_len + 1, conf);
options = p;
}
WSREP_DUMMY(w)->options = options;
return WSREP_OK; return WSREP_OK;
} }
static char* dummy_options_get (wsrep_t* w) static char* dummy_options_get (wsrep_t* w)
{ {
WSREP_DBUG_ENTER(w); WSREP_DBUG_ENTER(w);
return WSREP_DUMMY(w)->options; return NULL;
} }
static wsrep_status_t dummy_connect( static wsrep_status_t dummy_connect(
...@@ -423,8 +385,6 @@ int wsrep_dummy_loader(wsrep_t* w) ...@@ -423,8 +385,6 @@ int wsrep_dummy_loader(wsrep_t* w)
// initialize private context // initialize private context
WSREP_DUMMY(w)->log_fn = NULL; WSREP_DUMMY(w)->log_fn = NULL;
WSREP_DUMMY(w)->options = NULL;
return 0; return 0;
} }
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