Skip to content

Commit

Permalink
bzr merge -r3968..3984 codership/5.5 (non-Innodb changes only).
Browse files Browse the repository at this point in the history
  • Loading branch information
Nirbhay Choubey committed May 21, 2014
1 parent 8a6f4e1 commit 99df0fb
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 111 deletions.
10 changes: 5 additions & 5 deletions scripts/wsrep_sst_common.sh
Expand Up @@ -20,6 +20,7 @@ set -u

WSREP_SST_OPT_BYPASS=0
WSREP_SST_OPT_DATA=""
WSREP_SST_OPT_AUTH=""

while [ $# -gt 0 ]; do
case "$1" in
Expand Down Expand Up @@ -55,7 +56,7 @@ case "$1" in
shift
;;
'--password')
readonly WSREP_SST_OPT_PSWD="$2"
WSREP_SST_OPT_PSWD="$2"
shift
;;
'--port')
Expand All @@ -71,7 +72,7 @@ case "$1" in
shift
;;
'--user')
readonly WSREP_SST_OPT_USER="$2"
WSREP_SST_OPT_USER="$2"
shift
;;
'--gtid')
Expand All @@ -88,8 +89,8 @@ done
readonly WSREP_SST_OPT_BYPASS

# For Bug:1200727
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 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
WSREP_SST_OPT_AUTH=$(my_print_defaults -c $WSREP_SST_OPT_CONF sst | grep -- "--wsrep_sst_auth" | cut -d= -f2)
fi
fi
Expand Down Expand Up @@ -124,4 +125,3 @@ wsrep_cleanup_progress_file()
{
[ -n "$SST_PROGRESS_FILE" ] && rm -f "$SST_PROGRESS_FILE" 2>/dev/null
}

16 changes: 11 additions & 5 deletions scripts/wsrep_sst_mysqldump.sh
@@ -1,15 +1,15 @@
#!/bin/sh -e
#!/bin/bash -e
# Copyright (C) 2009 Codership Oy
#
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to the
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston
Expand Down Expand Up @@ -65,6 +65,11 @@ then
exit $EINVAL
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"
if test -n "$WSREP_SST_OPT_PSWD"; then AUTH="$AUTH -p$WSREP_SST_OPT_PSWD"; fi

Expand Down Expand Up @@ -123,4 +128,5 @@ else
wsrep_log_info "Bypassing state dump."
echo $SET_START_POSITION | $MYSQL
fi

wsrep_cleanup_progress_file
#
34 changes: 20 additions & 14 deletions scripts/wsrep_sst_rsync.sh
Expand Up @@ -25,6 +25,9 @@ OS=$(uname)

. $(dirname $0)/wsrep_sst_common

# Setting the path for lsof on CentOS
export PATH="/usr/sbin:/sbin:$PATH"

cleanup_joiner()
{
wsrep_log_info "Joiner cleanup."
Expand All @@ -49,19 +52,21 @@ check_pid()
check_pid_and_port()
{
local pid_file=$1
local rsync_pid=$(cat $pid_file)
local rsync_port=$2

if [ "$OS" == "Darwin" -o "$OS" == "FreeBSD" ]; then
# no netstat --program(-p) option in Darwin and FreeBSD
check_pid $pid_file && \
lsof -i -Pn 2>/dev/null | \
grep "(LISTEN)" | grep ":$rsync_port" | grep -w '^rsync[[:space:]]\+'"$rsync_pid" >/dev/null
else
check_pid $pid_file && \
netstat -lnpt 2>/dev/null | \
grep LISTEN | grep \:$rsync_port | grep $rsync_pid/rsync >/dev/null
local rsync_pid=$2
local rsync_port=$3

local port_info=$(lsof -i :$rsync_port -Pn 2>/dev/null | \
grep "(LISTEN)")
local is_rsync=$(echo $port_info | \
grep -w '^rsync[[:space:]]\+'"$rsync_pid" 2>/dev/null)

if [ -n "$port_info" -a -z "$is_rsync" ]; then
wsrep_log_error "rsync daemon port '$rsync_port' has been taken"
exit 16 # EBUSY
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"
Expand Down Expand Up @@ -234,9 +239,10 @@ EOF
# rm -rf "$DATA"/ib_logfile* # we don't want old logs around

# 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
sleep 0.2
done
Expand Down
51 changes: 35 additions & 16 deletions sql/slave.cc
Expand Up @@ -4370,13 +4370,19 @@ pthread_handler_t handle_slave_sql(void *arg)
my_off_t saved_skip= 0;
Master_info *mi= ((Master_info*)arg);
Relay_log_info* rli = &mi->rli;
#ifdef WITH_WSREP
my_bool wsrep_node_dropped= FALSE;
#endif /* WITH_WSREP */
const char *errmsg;
rpl_group_info *serial_rgi;
rpl_sql_thread_info sql_info(mi->rpl_filter);

// needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
my_thread_init();
DBUG_ENTER("handle_slave_sql");
#ifdef WITH_WSREP
wsrep_restart_point:
#endif /* WITH_WSREP */

LINT_INIT(saved_master_log_pos);
LINT_INIT(saved_log_pos);
Expand Down Expand Up @@ -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"));
// do not scare the user if SQL thread was simply killed or stopped
if (!sql_slave_killed(serial_rgi))
{
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;
}
}
Expand Down Expand Up @@ -4702,6 +4716,27 @@ log '%s' at position %s, relay log '%s' position: %s%s", RPL_LOG_NAME,
delete serial_rgi;
delete thd;
mysql_mutex_unlock(&LOCK_thread_count);
#ifdef WITH_WSREP
/* 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
*/
if (wsrep_node_dropped && wsrep_restart_slave)
{
if (wsrep_ready)
{
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 "
"automatically restarted when node joins back to cluster");
wsrep_restart_slave_activated= TRUE;
}
}
#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
Expand All @@ -4711,22 +4746,6 @@ log '%s' at position %s, relay log '%s' position: %s%s", RPL_LOG_NAME,
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
/* 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
*/
if (WSREP_ON && !wsrep_ready)
{
WSREP_INFO("Slave thread stopped because node dropped from cluster");
if (wsrep_restart_slave)
{
WSREP_INFO("wsrep_restart_slave was set and therefore slave will be "
"automatically restarted when node joins back to cluster");
wsrep_restart_slave_activated= TRUE;
}
}
#endif /* WITH_WSREP */

DBUG_LEAVE; // Must match DBUG_ENTER()
my_thread_end();
#ifdef HAVE_OPENSSL
Expand Down
1 change: 1 addition & 0 deletions sql/sql_base.cc
Expand Up @@ -4598,6 +4598,7 @@ bool open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags,
thd->lex->sql_command== SQLCOM_LOAD ||
thd->lex->sql_command== SQLCOM_DELETE) &&
wsrep_replicate_myisam &&
(*start) &&
(*start)->table && (*start)->table->file->ht->db_type == DB_TYPE_MYISAM)
{
WSREP_TO_ISOLATION_BEGIN(NULL, NULL, (*start));
Expand Down
6 changes: 6 additions & 0 deletions sql/wsrep_hton.cc
Expand Up @@ -513,11 +513,17 @@ wsrep_run_wsrep_commit(THD *thd, handlerton *hton, bool all)

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:
WSREP_ERROR("connection failure");
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
DBUG_RETURN(WSREP_TRX_ERROR);
default:
WSREP_ERROR("unknown connection failure");
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
DBUG_RETURN(WSREP_TRX_ERROR);
}

Expand Down
43 changes: 29 additions & 14 deletions sql/wsrep_mysqld.cc
Expand Up @@ -64,10 +64,10 @@ ulong wsrep_mysql_replication_bundle = 0;
my_bool wsrep_desync = 0; // desynchronize the node from the
// cluster
my_bool wsrep_load_data_splitting = 1; // commit load data every 10K intervals
my_bool wsrep_restart_slave = 0; // should mysql slave thread be
my_bool wsrep_restart_slave = 0; // should mysql slave thread be
// restarted, if node joins back
my_bool wsrep_restart_slave_activated = 0; // node has dropped, and slave
// restart will be needed
my_bool wsrep_restart_slave_activated = 0; // node has dropped, and slave
// restart will be needed
/*
* End configuration options
*/
Expand Down Expand Up @@ -433,9 +433,22 @@ static void wsrep_synced_cb(void* app_ctx)
}
if (wsrep_restart_slave_activated)
{
int rcode;
WSREP_INFO("MySQL slave restart");
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);

}
}

Expand Down Expand Up @@ -526,6 +539,7 @@ int wsrep_init()
{
DBUG_PRINT("wsrep",("wsrep::init() failed: %d", rcode));
WSREP_ERROR("wsrep::init() failed: %d, must shutdown", rcode);
wsrep->free(wsrep);
free(wsrep);
wsrep = NULL;
}
Expand Down Expand Up @@ -670,6 +684,7 @@ int wsrep_init()
{
DBUG_PRINT("wsrep",("wsrep::init() failed: %d", rcode));
WSREP_ERROR("wsrep::init() failed: %d, must shutdown", rcode);
wsrep->free(wsrep);
free(wsrep);
wsrep = NULL;
} else {
Expand Down Expand Up @@ -1214,7 +1229,7 @@ create_view_query(THD *thd, uchar** buf, size_t* buf_len)
}
buff.append(STRING_WITH_LEN(" AS "));
//buff.append(views->source.str, views->source.length);
buff.append(thd->lex->create_view_select.str,
buff.append(thd->lex->create_view_select.str,
thd->lex->create_view_select.length);
//int errcode= query_error_code(thd, TRUE);
//if (thd->binlog_query(THD::STMT_QUERY_TYPE,
Expand All @@ -1223,7 +1238,7 @@ create_view_query(THD *thd, uchar** buf, size_t* buf_len)
}

static int wsrep_TOI_begin(THD *thd, char *db_, char *table_,
const TABLE_LIST* table_list)
const TABLE_LIST* table_list)
{
wsrep_status_t ret(WSREP_WARNING);
uchar* buf(0);
Expand All @@ -1248,7 +1263,7 @@ static int wsrep_TOI_begin(THD *thd, char *db_, char *table_,
buf_err= wsrep_create_event_query(thd, &buf, &buf_len);
break;
default:
buf_err= wsrep_to_buf_helper(thd, thd->query(), thd->query_length(), &buf,
buf_err= wsrep_to_buf_helper(thd, thd->query(), thd->query_length(), &buf,
&buf_len);
break;
}
Expand Down Expand Up @@ -1298,7 +1313,7 @@ static void wsrep_TOI_end(THD *thd) {
}
}

static int wsrep_RSU_begin(THD *thd, char *db_, char *table_)
static int wsrep_RSU_begin(THD *thd, char *db_, char *table_)
{
wsrep_status_t ret(WSREP_WARNING);
WSREP_DEBUG("RSU BEGIN: %lld, %d : %s", (long long)wsrep_thd_trx_seqno(thd),
Expand Down Expand Up @@ -1380,9 +1395,9 @@ int wsrep_to_isolation_begin(THD *thd, char *db_, char *table_,
int ret= 0;
mysql_mutex_lock(&thd->LOCK_wsrep_thd);

if (thd->wsrep_conflict_state == MUST_ABORT)
if (thd->wsrep_conflict_state == MUST_ABORT)
{
WSREP_INFO("thread: %lu, %s has been aborted due to multi-master conflict",
WSREP_INFO("thread: %lu, %s has been aborted due to multi-master conflict",
thd->thread_id, thd->query());
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
return WSREP_TRX_FAIL;
Expand All @@ -1401,7 +1416,7 @@ int wsrep_to_isolation_begin(THD *thd, char *db_, char *table_,

if (wsrep_debug && thd->mdl_context.has_locks())
{
WSREP_DEBUG("thread holds MDL locks at TI begin: %s %lu",
WSREP_DEBUG("thread holds MDL locks at TI begin: %s %lu",
thd->query(), thd->thread_id);
}

Expand Down Expand Up @@ -1493,23 +1508,23 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
mysql_mutex_unlock(&granted_thd->LOCK_wsrep_thd);
ret = TRUE;
}
else if (request_thd->lex->sql_command == SQLCOM_DROP_TABLE)
else if (request_thd->lex->sql_command == SQLCOM_DROP_TABLE)
{
WSREP_DEBUG("DROP caused BF abort");
ticket->wsrep_report(wsrep_debug);
mysql_mutex_unlock(&granted_thd->LOCK_wsrep_thd);
wsrep_abort_thd((void*)request_thd, (void*)granted_thd, 1);
ret = FALSE;
}
else if (granted_thd->wsrep_query_state == QUERY_COMMITTING)
else if (granted_thd->wsrep_query_state == QUERY_COMMITTING)
{
WSREP_DEBUG("mdl granted, but commiting thd abort scheduled");
ticket->wsrep_report(wsrep_debug);
mysql_mutex_unlock(&granted_thd->LOCK_wsrep_thd);
wsrep_abort_thd((void*)request_thd, (void*)granted_thd, 1);
ret = FALSE;
}
else
else
{
WSREP_MDL_LOG(DEBUG, "MDL conflict-> BF abort", request_thd, granted_thd);
ticket->wsrep_report(wsrep_debug);
Expand Down

0 comments on commit 99df0fb

Please sign in to comment.