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

Merge lp:codership-mysql/5.5 -r3961..3980.

parent 150e88e8
......@@ -18,7 +18,7 @@
# so WSREP_VERSION is produced regardless
# Set the patch version
SET(WSREP_PATCH_VERSION "9")
SET(WSREP_PATCH_VERSION "10")
# MariaDB addition: Revision number of the last revision merged from
# codership branch visible in @@visible_comment.
......
......@@ -328,7 +328,13 @@ IF(WIN32)
ENDFOREACH()
ELSE()
IF(WITH_WSREP)
SET(WSREP_BINARIES wsrep_sst_common wsrep_sst_mysqldump wsrep_sst_rsync wsrep_sst_xtrabackup)
SET(WSREP_BINARIES
wsrep_sst_common
wsrep_sst_mysqldump
wsrep_sst_rsync
wsrep_sst_xtrabackup
wsrep_sst_xtrabackup-v2
)
ENDIF()
# Configure this one, for testing, but do not install it.
......
......@@ -28,7 +28,7 @@ case "$1" in
shift
;;
'--auth')
readonly WSREP_SST_OPT_AUTH="$2"
WSREP_SST_OPT_AUTH="$2"
shift
;;
'--bypass')
......@@ -87,13 +87,21 @@ shift
done
readonly WSREP_SST_OPT_BYPASS
if [ -n "$WSREP_SST_OPT_DATA" ]
# 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
WSREP_SST_OPT_AUTH=$(my_print_defaults -c $WSREP_SST_OPT_CONF sst | grep -- "--wsrep_sst_auth" | cut -d= -f2)
fi
fi
if [ -n "${WSREP_SST_OPT_DATA:-}" ]
then
SST_PROGRESS_FILE="$WSREP_SST_OPT_DATA/sst_in_progress"
else
SST_PROGRESS_FILE=""
fi
wsrep_log()
{
# echo everything to stderr so that it gets into common error log
......
......@@ -28,7 +28,7 @@ case "$1" in
shift
;;
'--auth')
readonly WSREP_SST_OPT_AUTH="$2"
WSREP_SST_OPT_AUTH="$2"
shift
;;
'--bypass')
......@@ -87,13 +87,21 @@ shift
done
readonly WSREP_SST_OPT_BYPASS
if [ -n "$WSREP_SST_OPT_DATA" ]
# 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
WSREP_SST_OPT_AUTH=$(my_print_defaults -c $WSREP_SST_OPT_CONF sst | grep -- "--wsrep_sst_auth" | cut -d= -f2)
fi
fi
if [ -n "${WSREP_SST_OPT_DATA:-}" ]
then
SST_PROGRESS_FILE="$WSREP_SST_OPT_DATA/sst_in_progress"
else
SST_PROGRESS_FILE=""
fi
wsrep_log()
{
# echo everything to stderr so that it gets into common error log
......
......@@ -49,19 +49,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"
......@@ -234,9 +236,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
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -3456,12 +3456,18 @@ pthread_handler_t handle_slave_sql(void *arg)
my_off_t UNINIT_VAR(saved_log_pos);
my_off_t UNINIT_VAR(saved_master_log_pos);
my_off_t saved_skip= 0;
#ifdef WITH_WSREP
my_bool wsrep_node_dropped= FALSE;
#endif /* WITH_WSREP */
Relay_log_info* rli = &((Master_info*)arg)->rli;
const char *errmsg;
// 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);
......@@ -3727,6 +3733,12 @@ log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME,
Error running query, slave SQL thread aborted. Fix the problem, and restart \
the slave SQL thread with \"SLAVE START\". We stopped at log \
'%s' position %s", RPL_LOG_NAME, llstr(rli->group_master_log_pos, llbuff));
#ifdef WITH_WSREP
if (WSREP_ON && last_errno == ER_UNKNOWN_COM_ERROR)
{
wsrep_node_dropped= TRUE;
}
#endif /* WITH_WSREP */
}
goto err;
}
......@@ -3791,6 +3803,27 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \
THD_CHECK_SENTRY(thd);
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
......
......@@ -5181,6 +5181,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));
......
......@@ -3918,6 +3918,10 @@ static Sys_var_mybool Sys_wsrep_load_data_splitting(
"transaction after every 10K rows inserted",
GLOBAL_VAR(wsrep_load_data_splitting),
CMD_LINE(OPT_ARG), DEFAULT(TRUE));
static Sys_var_mybool Sys_wsrep_restart_slave(
"wsrep_restart_slave", "Should MySQL slave be restarted automatically, when node joins back to cluster",
GLOBAL_VAR(wsrep_restart_slave), CMD_LINE(OPT_ARG), DEFAULT(FALSE));
#endif /* WITH_WSREP */
static Sys_var_charptr Sys_ignore_db_dirs(
......
......@@ -320,3 +320,59 @@ void wsrep_dump_rbr_buf(THD *thd, const void* rbr_buf, size_t buf_len)
}
}
void wsrep_dump_rbr_direct(THD* thd, IO_CACHE* cache)
{
char filename[PATH_MAX]= {0};
int len= snprintf(filename, PATH_MAX, "%s/GRA_%ld_%lld.log",
wsrep_data_home_dir, thd->thread_id,
(long long)wsrep_thd_trx_seqno(thd));
size_t bytes_in_cache = 0;
// check path
if (len >= PATH_MAX)
{
WSREP_ERROR("RBR dump path too long: %d, skipping dump.", len);
return ;
}
// init cache
my_off_t const saved_pos(my_b_tell(cache));
if (reinit_io_cache(cache, READ_CACHE, 0, 0, 0))
{
WSREP_ERROR("failed to initialize io-cache");
return ;
}
// open file
FILE* of = fopen(filename, "wb");
if (!of)
{
WSREP_ERROR("Failed to open file '%s': %d (%s)",
filename, errno, strerror(errno));
goto cleanup;
}
// ready to write
bytes_in_cache= my_b_bytes_in_cache(cache);
if (unlikely(bytes_in_cache == 0)) bytes_in_cache = my_b_fill(cache);
if (likely(bytes_in_cache > 0)) do
{
if (my_fwrite(of, cache->read_pos, bytes_in_cache,
MYF(MY_WME | MY_NABP)) == (size_t) -1)
{
WSREP_ERROR("Failed to write file '%s'", filename);
goto cleanup;
}
cache->read_pos= cache->read_end;
} while ((cache->file >= 0) && (bytes_in_cache= my_b_fill(cache)));
if(cache->error == -1)
{
WSREP_ERROR("RBR inconsistent");
goto cleanup;
}
cleanup:
// init back
if (reinit_io_cache(cache, WRITE_CACHE, saved_pos, 0, 0))
{
WSREP_ERROR("failed to reinitialize io-cache");
}
// close file
if (of) fclose(of);
}
......@@ -46,4 +46,7 @@ int wsrep_write_cache (wsrep_t* wsrep,
/* Dump replication buffer to disk */
void wsrep_dump_rbr_buf(THD *thd, const void* rbr_buf, size_t buf_len);
/* Dump replication buffer to disk without intermediate buffer */
void wsrep_dump_rbr_direct(THD* thd, IO_CACHE* cache);
#endif /* WSREP_BINLOG_H */
......@@ -505,11 +505,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);
}
......
......@@ -26,6 +26,7 @@
#include <cstdio>
#include <cstdlib>
#include "log_event.h"
#include <slave.h>
Format_description_log_event *wsrep_format_desc = NULL;
wsrep_t *wsrep = NULL;
......@@ -59,7 +60,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
// restarted, if node joins back
my_bool wsrep_restart_slave_activated = 0; // node has dropped, and slave
// restart will be needed
/*
* End configuration options
*/
......@@ -406,6 +410,25 @@ static void wsrep_synced_cb(void* app_ctx)
// and wait for SE initialization
wsrep_SE_init_wait();
}
if (wsrep_restart_slave_activated)
{
int rcode;
WSREP_INFO("MySQL slave restart");
wsrep_restart_slave_activated= FALSE;
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);
}
}
static void wsrep_init_position()
......@@ -627,6 +650,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 {
......@@ -1159,7 +1183,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,
......@@ -1168,7 +1192,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);
......@@ -1193,7 +1217,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;
}
......@@ -1243,7 +1267,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),
......@@ -1325,9 +1349,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;
......@@ -1346,7 +1370,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);
}
......@@ -1438,7 +1462,7 @@ 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);
......@@ -1446,7 +1470,7 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
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);
......@@ -1454,7 +1478,7 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
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);
......
......@@ -95,6 +95,8 @@ extern my_bool wsrep_replicate_myisam;
extern my_bool wsrep_log_conflicts;
extern ulong wsrep_mysql_replication_bundle;
extern my_bool wsrep_load_data_splitting;
extern my_bool wsrep_restart_slave;
extern my_bool wsrep_restart_slave_activated;
enum enum_wsrep_OSU_method { WSREP_OSU_TOI, WSREP_OSU_RSU };
......
......@@ -75,15 +75,18 @@ void wsrep_notify_status (wsrep_member_status_t status,
cmd_off += snprintf (cmd_ptr + cmd_off, cmd_len - cmd_off,
" --index %d", view->my_idx);
cmd_off += snprintf (cmd_ptr + cmd_off, cmd_len - cmd_off, " --members");
for (int i = 0; i < view->memb_num; i++)
if (view->memb_num)
{
wsrep_uuid_print (&view->members[i].id, uuid_str, sizeof(uuid_str));
cmd_off += snprintf (cmd_ptr + cmd_off, cmd_len - cmd_off,
"%c%s/%s/%s", i > 0 ? ',' : ' ',
uuid_str, view->members[i].name,
view->members[i].incoming);
cmd_off += snprintf (cmd_ptr + cmd_off, cmd_len - cmd_off, " --members");
for (int i = 0; i < view->memb_num; i++)
{
wsrep_uuid_print (&view->members[i].id, uuid_str, sizeof(uuid_str));
cmd_off += snprintf (cmd_ptr + cmd_off, cmd_len - cmd_off,
"%c%s/%s/%s", i > 0 ? ',' : ' ',
uuid_str, view->members[i].name,
view->members[i].incoming);
}
}
}
......
......@@ -934,8 +934,9 @@ static void* sst_donor_thread (void* a)
else
{
WSREP_ERROR("Failed to read from: %s", proc.cmd());
proc.wait();
}
if (err && proc.error()) err= proc.error();
if (!err && proc.error()) err= proc.error();
}
else
{
......
......@@ -1207,6 +1207,7 @@ echo "=====" >> $STATUS_HISTORY
%attr(755, root, root) %{_bindir}/wsrep_sst_rsync
%attr(755, root, root) %{_bindir}/wsrep_sst_rsync_wan
%attr(755, root, root) %{_bindir}/wsrep_sst_xtrabackup
%attr(755, root, root) %{_bindir}/wsrep_sst_xtrabackup-v2
%endif
%attr(755, root, root) %{_sbindir}/mysqld
......
......@@ -87,6 +87,7 @@ do
--members)
MEMBERS=$2
shift
fi
;;
esac
shift
......
......@@ -137,7 +137,11 @@ typedef void (*wsrep_log_cb_t)(wsrep_log_level_t, const char *);
typedef uint64_t wsrep_trx_id_t; //!< application transaction ID
typedef uint64_t wsrep_conn_id_t; //!< application connection ID
typedef int64_t wsrep_seqno_t; //!< sequence number of a writeset, etc.
#ifdef __cplusplus
typedef bool wsrep_bool_t;
#else
typedef _Bool wsrep_bool_t; //!< should be the same as standard (C99) bool
#endif /* __cplusplus */
/*! undefined seqno */
#define WSREP_SEQNO_UNDEFINED (-1)
......
......@@ -388,4 +388,3 @@ int wsrep_dummy_loader(wsrep_t* w)
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