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
local rsync_pid=$2
local rsync_port=$3
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 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 {
......
......@@ -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,6 +75,8 @@ 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);
if (view->memb_num)
{
cmd_off += snprintf (cmd_ptr + cmd_off, cmd_len - cmd_off, " --members");
for (int i = 0; i < view->memb_num; i++)
......@@ -86,6 +88,7 @@ void wsrep_notify_status (wsrep_member_status_t status,
view->members[i].incoming);
}
}
}
if (cmd_off == cmd_len)
{
......
......@@ -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