summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/lock.cc18
-rw-r--r--sql/mdl.cc30
-rw-r--r--sql/mdl.h3
-rw-r--r--sql/mysqld.cc104
-rw-r--r--sql/slave.cc6
-rw-r--r--sql/sql_parse.cc29
-rw-r--r--sql/sys_vars.cc8
-rw-r--r--sql/wsrep_mysqld.cc60
-rw-r--r--sql/wsrep_mysqld.h10
-rw-r--r--sql/wsrep_sst.cc4
-rw-r--r--sql/wsrep_utils.cc5
-rw-r--r--sql/wsrep_var.cc46
12 files changed, 210 insertions, 113 deletions
diff --git a/sql/lock.cc b/sql/lock.cc
index 854e7ddf78d..c8ca26561e6 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -1121,6 +1121,15 @@ bool Global_read_lock::make_global_read_lock_block_commit(THD *thd)
if (m_state != GRL_ACQUIRED)
DBUG_RETURN(0);
+ mdl_request.init(MDL_key::COMMIT, "", "", MDL_SHARED, MDL_EXPLICIT);
+
+ if (thd->mdl_context.acquire_lock(&mdl_request,
+ thd->variables.lock_wait_timeout))
+ DBUG_RETURN(TRUE);
+
+ m_mdl_blocks_commits_lock= mdl_request.ticket;
+ m_state= GRL_ACQUIRED_AND_BLOCKS_COMMIT;
+
#ifdef WITH_WSREP
long long ret = wsrep->pause(wsrep);
if (ret >= 0)
@@ -1137,15 +1146,6 @@ bool Global_read_lock::make_global_read_lock_block_commit(THD *thd)
DBUG_RETURN(TRUE);
}
#endif /* WITH_WSREP */
- mdl_request.init(MDL_key::COMMIT, "", "", MDL_SHARED, MDL_EXPLICIT);
-
- if (thd->mdl_context.acquire_lock(&mdl_request,
- thd->variables.lock_wait_timeout))
- DBUG_RETURN(TRUE);
-
- m_mdl_blocks_commits_lock= mdl_request.ticket;
- m_state= GRL_ACQUIRED_AND_BLOCKS_COMMIT;
-
DBUG_RETURN(FALSE);
}
diff --git a/sql/mdl.cc b/sql/mdl.cc
index 8527c027937..e2c633b486e 100644
--- a/sql/mdl.cc
+++ b/sql/mdl.cc
@@ -3015,3 +3015,33 @@ void MDL_context::set_transaction_duration_for_all_locks()
ticket->m_duration= MDL_TRANSACTION;
#endif
}
+#ifdef WITH_WSREP
+void MDL_ticket::wsrep_report(bool debug)
+{
+ if (debug)
+ {
+ WSREP_DEBUG("MDL ticket: type: %s space: %s db: %s name: %s (%s)",
+ (get_type() == MDL_INTENTION_EXCLUSIVE) ? "intention exclusive" :
+ ((get_type() == MDL_SHARED) ? "shared" :
+ ((get_type() == MDL_SHARED_HIGH_PRIO ? "shared high prio" :
+ ((get_type() == MDL_SHARED_READ) ? "shared read" :
+ ((get_type() == MDL_SHARED_WRITE) ? "shared write" :
+ ((get_type() == MDL_SHARED_NO_WRITE) ? "shared no write" :
+ ((get_type() == MDL_SHARED_NO_READ_WRITE) ? "shared no read write" :
+ ((get_type() == MDL_EXCLUSIVE) ? "exclusive" :
+ "UNKNOWN")))))))),
+ (m_lock->key.mdl_namespace() == MDL_key::GLOBAL) ? "GLOBAL" :
+ ((m_lock->key.mdl_namespace() == MDL_key::SCHEMA) ? "SCHEMA" :
+ ((m_lock->key.mdl_namespace() == MDL_key::TABLE) ? "TABLE" :
+ ((m_lock->key.mdl_namespace() == MDL_key::TABLE) ? "FUNCTION" :
+ ((m_lock->key.mdl_namespace() == MDL_key::TABLE) ? "PROCEDURE" :
+ ((m_lock->key.mdl_namespace() == MDL_key::TABLE) ? "TRIGGER" :
+ ((m_lock->key.mdl_namespace() == MDL_key::TABLE) ? "EVENT" :
+ ((m_lock->key.mdl_namespace() == MDL_key::COMMIT) ? "COMMIT" :
+ (char *)"UNKNOWN"))))))),
+ m_lock->key.db_name(),
+ m_lock->key.name(),
+ m_lock->key.get_wait_state_name());
+ }
+}
+#endif /* WITH_WSREP */
diff --git a/sql/mdl.h b/sql/mdl.h
index af7d75c1297..0f99b759c0e 100644
--- a/sql/mdl.h
+++ b/sql/mdl.h
@@ -475,6 +475,9 @@ public:
MDL_ticket *next_in_lock;
MDL_ticket **prev_in_lock;
public:
+#ifdef WITH_WSREP
+ void wsrep_report(bool debug);
+#endif /* WITH_WSREP */
bool has_pending_conflicting_lock() const;
MDL_context *get_ctx() const { return m_ctx; }
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 45e4f6fe905..b441c31b28d 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -3639,7 +3639,13 @@ static int init_common_variables()
}
else
opt_log_basename= glob_hostname;
-
+#ifdef WITH_WSREP
+ if (0 == wsrep_node_name || 0 == wsrep_node_name[0])
+ {
+ my_free((void *)wsrep_node_name);
+ wsrep_node_name= my_strdup(glob_hostname, MYF(MY_WME));
+ }
+#endif /* WITH_WSREP */
if (!*pidfile_name)
{
strmake(pidfile_name, opt_log_basename, sizeof(pidfile_name)-5);
@@ -4390,29 +4396,37 @@ will be ignored as the --log-bin option is not defined.");
}
#endif
-/* WSREP BEFORE */
-#ifdef WITH_WSREP
- // add basedir/bin to PATH to resolve wsrep script names
- char* const tmp_path((char*)alloca(strlen(mysql_home) + strlen("/bin") + 1));
- if (tmp_path)
+#ifdef WITH_WSREP /* WSREP BEFORE SE */
+ if (!wsrep_recovery)
{
- strcpy(tmp_path, mysql_home);
- strcat(tmp_path, "/bin");
- wsrep_prepend_PATH(tmp_path);
- }
- else
- {
- WSREP_ERROR("Could not append %s/bin to PATH", mysql_home);
- }
+ if (opt_bootstrap) // bootsrap option given - disable wsrep functionality
+ {
+ wsrep_provider_init(WSREP_NONE);
+ if (wsrep_init()) unireg_abort(1);
+ }
+ else // full wsrep initialization
+ {
+ // add basedir/bin to PATH to resolve wsrep script names
+ char* const tmp_path((char*)alloca(strlen(mysql_home) +
+ strlen("/bin") + 1));
+ if (tmp_path)
+ {
+ strcpy(tmp_path, mysql_home);
+ strcat(tmp_path, "/bin");
+ wsrep_prepend_PATH(tmp_path);
+ }
+ else
+ {
+ WSREP_ERROR("Could not append %s/bin to PATH", mysql_home);
+ }
- if (opt_bootstrap)
- {
- wsrep_provider_init(WSREP_NONE);
- if (wsrep_init()) unireg_abort(1);
- }
- else if (!wsrep_recovery && wsrep_init_first())
- {
- wsrep_init_startup(true);
+ if (wsrep_before_SE())
+ {
+ set_ports(); // this is also called in network_init() later but we need
+ // to know mysqld_port now - lp:1071882
+ wsrep_init_startup(true);
+ }
+ }
}
#endif /* WITH_WSREP */
if (opt_bin_log)
@@ -5622,32 +5636,37 @@ int mysqld_main(int argc, char **argv)
if (Events::init(opt_noacl || opt_bootstrap))
unireg_abort(1);
-/* WSREP AFTER */
-#ifdef WITH_WSREP
- wsrep_SE_initialized();
- if (opt_bootstrap)
- {
- /*! bootstrap wsrep init was taken care of above */
- }
- else if (wsrep_recovery)
+#ifdef WITH_WSREP /* WSREP AFTER SE */
+ if (wsrep_recovery)
{
select_thread_in_use= 0;
wsrep_recover();
unireg_abort(0);
}
- else if (wsrep_init_first())
+
+ if (opt_bootstrap)
{
- /*! in case of no SST wsrep waits in view handler callback */
- wsrep_SE_init_grab();
- wsrep_SE_init_done();
- /*! in case of SST wsrep waits for wsrep->sst_received */
- wsrep_sst_continue();
+ /*! bootstrap wsrep init was taken care of above */
}
else
{
- wsrep_init_startup (false);
+ wsrep_SE_initialized();
+
+ if (wsrep_before_SE())
+ {
+ /*! in case of no SST wsrep waits in view handler callback */
+ wsrep_SE_init_grab();
+ wsrep_SE_init_done();
+ /*! in case of SST wsrep waits for wsrep->sst_received */
+ wsrep_sst_continue();
+ }
+ else
+ {
+ wsrep_init_startup (false);
+ }
+
+ wsrep_create_appliers(wsrep_slave_threads - 1);
}
- wsrep_create_appliers(wsrep_slave_threads - 1);
#endif /* WITH_WSREP */
if (opt_bootstrap)
{
@@ -8451,15 +8470,6 @@ mysqld_get_one_option(int optid,
lower_case_table_names_used= 1;
break;
#ifdef WITH_WSREP
- case OPT_WSREP_PROVIDER:
- wsrep_provider_init (argument);
- break;
- case OPT_WSREP_PROVIDER_OPTIONS:
- wsrep_provider_options_init (argument);
- break;
- case OPT_WSREP_CLUSTER_ADDRESS:
- wsrep_cluster_address_init (argument);
- break;
case OPT_WSREP_START_POSITION:
wsrep_start_position_init (argument);
break;
diff --git a/sql/slave.cc b/sql/slave.cc
index b928b658f51..7e082971d6c 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -2601,10 +2601,10 @@ int apply_event_and_update_pos(Log_event* ev, THD* thd, Relay_log_info* rli)
int reason= ev->shall_skip(rli);
#ifdef WITH_WSREP
- if (ev->get_type_code() == XID_EVENT ||
+ if (WSREP_ON && (ev->get_type_code() == XID_EVENT ||
(ev->get_type_code() == QUERY_EVENT && thd->wsrep_mysql_replicated > 0 &&
(!strncasecmp(((Query_log_event*)ev)->query , "BEGIN", 5) ||
- !strncasecmp(((Query_log_event*)ev)->query , "COMMIT", 6) )))
+ !strncasecmp(((Query_log_event*)ev)->query , "COMMIT", 6) ))))
{
if (++thd->wsrep_mysql_replicated < (int)wsrep_mysql_replication_bundle)
{
@@ -3568,7 +3568,7 @@ pthread_handler_t handle_slave_sql(void *arg)
#ifdef WITH_WSREP
thd->wsrep_exec_mode= LOCAL_STATE;
/* synchronize with wsrep replication */
- wsrep_ready_wait ();
+ if (WSREP_ON) wsrep_ready_wait();
#endif
DBUG_PRINT("master_info",("log_file_name: %s position: %s",
rli->group_master_log_name,
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 1e9561e895b..03398987818 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1059,7 +1059,11 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thd->mysys_var->abort = 0;
thd->wsrep_conflict_state = NO_CONFLICT;
thd->wsrep_retry_counter = 0;
-
+ /*
+ Increment threads running to compensate dec_thread_running() called
+ after dispatch_end label.
+ */
+ inc_thread_running();
goto dispatch_end;
}
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
@@ -4883,7 +4887,6 @@ finish:
thd_proc_info(thd, "closing tables");
close_thread_tables(thd);
#ifdef WITH_WSREP
- WSREP_TO_ISOLATION_END
thd->wsrep_consistency_check= NO_CONSISTENCY_CHECK;
#endif /* WITH_WSREP */
thd_proc_info(thd, 0);
@@ -4922,6 +4925,7 @@ finish:
{
thd->mdl_context.release_statement_locks();
}
+ WSREP_TO_ISOLATION_END
DBUG_RETURN(res || thd->is_error());
}
@@ -6127,14 +6131,14 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
{
mysql_reset_thd_for_next_command(thd, opt_userstat_running);
thd->killed= NOT_KILLED;
- if (is_autocommit &&
- (thd->wsrep_retry_counter < thd->variables.wsrep_retry_autocommit))
+ if (is_autocommit &&
+ thd->lex->sql_command != SQLCOM_SELECT &&
+ (thd->wsrep_retry_counter < thd->variables.wsrep_retry_autocommit))
{
WSREP_DEBUG("wsrep retrying AC query: %s",
(thd->query()) ? thd->query() : "void");
-
- close_thread_tables(thd);
+ close_thread_tables(thd);
thd->wsrep_conflict_state= RETRY_AUTOCOMMIT;
thd->wsrep_retry_counter++; // grow
@@ -6166,7 +6170,12 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
if (thd->wsrep_retry_query)
{
- WSREP_DEBUG("releasing retry_query: %s", thd->wsrep_retry_query);
+ WSREP_DEBUG("releasing retry_query: conf %d sent %d kill %d errno %d SQL %s",
+ thd->wsrep_conflict_state,
+ thd->stmt_da->is_sent,
+ thd->killed,
+ thd->stmt_da->is_error() ? thd->stmt_da->sql_errno() : 0,
+ thd->wsrep_retry_query);
my_free(thd->wsrep_retry_query);
thd->wsrep_retry_query = NULL;
thd->wsrep_retry_query_len = 0;
@@ -8316,8 +8325,6 @@ void wsrep_replication_process(THD *thd)
struct wsrep_thd_shadow shadow;
wsrep_prepare_bf_thd(thd, &shadow);
- wsrep_format_desc= new Format_description_log_event(4);
-
rcode = wsrep->recv(wsrep, (void *)thd);
DBUG_PRINT("wsrep",("wsrep_repl returned: %d", rcode));
@@ -8428,8 +8435,8 @@ void wsrep_rollback_process(THD *thd)
mysql_mutex_lock(&aborting->LOCK_wsrep_thd);
wsrep_client_rollback(aborting);
- WSREP_DEBUG("WSREP rollbacker aborted thd: %llu",
- (long long)aborting->real_id);
+ WSREP_DEBUG("WSREP rollbacker aborted thd: (%lu %llu)",
+ aborting->thread_id, (long long)aborting->real_id);
mysql_mutex_unlock(&aborting->LOCK_wsrep_thd);
mysql_mutex_lock(&LOCK_wsrep_rollback);
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 49be8e79e3b..1efe724e6f9 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -3620,7 +3620,7 @@ static Sys_var_tz Sys_time_zone(
static Sys_var_charptr Sys_wsrep_provider(
"wsrep_provider", "Path to replication provider library",
- GLOBAL_VAR(wsrep_provider), CMD_LINE(REQUIRED_ARG, OPT_WSREP_PROVIDER),
+ PREALLOCATED GLOBAL_VAR(wsrep_provider), CMD_LINE(REQUIRED_ARG, OPT_WSREP_PROVIDER),
IN_FS_CHARSET, DEFAULT(wsrep_provider),
// IN_FS_CHARSET, DEFAULT(wsrep_provider_default),
NO_MUTEX_GUARD, NOT_IN_BINLOG,
@@ -3628,7 +3628,7 @@ static Sys_var_charptr Sys_wsrep_provider(
static Sys_var_charptr Sys_wsrep_provider_options(
"wsrep_provider_options", "provider specific options",
- GLOBAL_VAR(wsrep_provider_options),
+ PREALLOCATED GLOBAL_VAR(wsrep_provider_options),
CMD_LINE(REQUIRED_ARG, OPT_WSREP_PROVIDER_OPTIONS),
IN_FS_CHARSET, DEFAULT(wsrep_provider_options),
NO_MUTEX_GUARD, NOT_IN_BINLOG,
@@ -3652,7 +3652,7 @@ static Sys_var_charptr Sys_wsrep_cluster_name(
static PolyLock_mutex PLock_wsrep_slave_threads(&LOCK_wsrep_slave_threads);
static Sys_var_charptr Sys_wsrep_cluster_address (
"wsrep_cluster_address", "Address to initially connect to cluster",
- GLOBAL_VAR(wsrep_cluster_address),
+ PREALLOCATED GLOBAL_VAR(wsrep_cluster_address),
CMD_LINE(REQUIRED_ARG, OPT_WSREP_CLUSTER_ADDRESS),
IN_FS_CHARSET, DEFAULT(wsrep_cluster_address),
&PLock_wsrep_slave_threads, NOT_IN_BINLOG,
@@ -3741,7 +3741,7 @@ static Sys_var_charptr Sys_wsrep_sst_receive_address(
static Sys_var_charptr Sys_wsrep_sst_auth(
"wsrep_sst_auth", "Authentication for SST connection",
- GLOBAL_VAR(wsrep_sst_auth), CMD_LINE(REQUIRED_ARG, OPT_WSREP_SST_AUTH),
+ PREALLOCATED GLOBAL_VAR(wsrep_sst_auth), CMD_LINE(REQUIRED_ARG, OPT_WSREP_SST_AUTH),
IN_FS_CHARSET, DEFAULT(wsrep_sst_auth), NO_MUTEX_GUARD,
NOT_IN_BINLOG,
ON_CHECK(wsrep_sst_auth_check),
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index c31c02e6d33..62397c58a6e 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -21,6 +21,7 @@
#include <cstdlib>
#include "log_event.h"
+extern Format_description_log_event *wsrep_format_desc;
wsrep_t *wsrep = NULL;
my_bool wsrep_emulate_bin_log = FALSE; // activating parts of binlog interface
@@ -94,6 +95,11 @@ wsrep_seqno_t local_seqno = WSREP_SEQNO_UNDEFINED;
wsp::node_status local_status;
long wsrep_protocol_version = 2;
+// Boolean denoting if server is in initial startup phase. This is needed
+// to make sure that main thread waiting in wsrep_sst_wait() is signaled
+// if there was no state gap on receiving first view event.
+static my_bool wsrep_startup = TRUE;
+
// action execute callback
extern wsrep_status_t wsrep_apply_cb(void *ctx,
const void* buf, size_t buf_len,
@@ -283,13 +289,12 @@ static void wsrep_view_handler_cb (void* app_ctx,
* NOTE: Initialize wsrep_group_uuid here only if it wasn't initialized
* before - OR - it was reinitilized on startup (lp:992840)
*/
- if (!memcmp (&local_uuid, &WSREP_UUID_UNDEFINED, sizeof(wsrep_uuid_t)) ||
- 0 == wsrep_cluster_conf_id)
+ if (wsrep_startup)
{
- if (wsrep_init_first())
+ if (wsrep_before_SE())
{
wsrep_SE_init_grab();
- // Signal init thread to continue
+ // Signal mysqld init thread to continue
wsrep_sst_complete (&cluster_uuid, view->seqno, false);
// and wait for SE initialization
wsrep_SE_init_wait();
@@ -305,15 +310,14 @@ static void wsrep_view_handler_cb (void* app_ctx,
wsrep_set_SE_checkpoint(&xid);
new_status= WSREP_MEMBER_JOINED;
}
- else // just some sanity check
+
+ // just some sanity check
+ if (memcmp (&local_uuid, &cluster_uuid, sizeof (wsrep_uuid_t)))
{
- if (memcmp (&local_uuid, &cluster_uuid, sizeof (wsrep_uuid_t)))
- {
- WSREP_ERROR("Undetected state gap. Can't continue.");
- wsrep_log_states (WSREP_LOG_FATAL, &cluster_uuid, view->seqno,
- &local_uuid, -1);
- abort();
- }
+ WSREP_ERROR("Undetected state gap. Can't continue.");
+ wsrep_log_states(WSREP_LOG_FATAL, &cluster_uuid, view->seqno,
+ &local_uuid, -1);
+ unireg_abort(1);
}
}
@@ -324,7 +328,7 @@ static void wsrep_view_handler_cb (void* app_ctx,
}
out:
-
+ wsrep_startup= FALSE;
local_status.set(new_status, view);
}
@@ -415,7 +419,7 @@ int wsrep_init()
wsrep_ready_set(FALSE);
assert(wsrep_provider);
-
+ wsrep_format_desc= new Format_description_log_event(4);
wsrep_init_position();
if ((rcode= wsrep_load(wsrep_provider, &wsrep, wsrep_log_cb)) != WSREP_OK)
@@ -476,8 +480,10 @@ int wsrep_init()
}
static char inc_addr[512]= { 0, };
+
if ((!wsrep_node_incoming_address ||
- !strcmp (wsrep_node_incoming_address, WSREP_NODE_INCOMING_AUTO))) {
+ !strcmp (wsrep_node_incoming_address, WSREP_NODE_INCOMING_AUTO)))
+ {
size_t const node_addr_len= strlen(node_addr);
if (node_addr_len > 0)
{
@@ -579,6 +585,9 @@ void wsrep_deinit()
provider_name[0]= '\0';
provider_version[0]= '\0';
provider_vendor[0]= '\0';
+
+ delete wsrep_format_desc;
+ wsrep_format_desc= NULL;
}
void wsrep_recover()
@@ -1181,6 +1190,21 @@ int wsrep_to_isolation_begin(THD *thd, char *db_, char *table_,
const TABLE_LIST* table_list)
{
int ret= 0;
+ mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ if (thd->wsrep_conflict_state == MUST_ABORT)
+ {
+ 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;
+ }
+ mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+
+ if (wsrep_debug && thd->mdl_context.has_locks())
+ {
+ WSREP_DEBUG("thread holds MDL locks at TI begin: %s %lu",
+ thd->query(), thd->thread_id);
+ }
if (thd->variables.wsrep_on && thd->wsrep_exec_mode==LOCAL_STATE)
{
switch (wsrep_OSU_method_options) {
@@ -1236,24 +1260,28 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
{
mysql_mutex_unlock(&request_thd->LOCK_wsrep_thd);
WSREP_MDL_LOG(DEBUG, "MDL conflict ", request_thd, granted_thd);
+ ticket->wsrep_report(wsrep_debug);
mysql_mutex_lock(&granted_thd->LOCK_wsrep_thd);
if (granted_thd->wsrep_exec_mode == TOTAL_ORDER ||
granted_thd->wsrep_exec_mode == REPL_RECV)
{
WSREP_MDL_LOG(INFO, "MDL BF-BF conflict", request_thd, granted_thd);
+ ticket->wsrep_report(true);
mysql_mutex_unlock(&granted_thd->LOCK_wsrep_thd);
ret = TRUE;
}
else if (granted_thd->lex->sql_command == SQLCOM_FLUSH)
{
WSREP_DEBUG("mdl granted over FLUSH BF");
+ ticket->wsrep_report(wsrep_debug);
mysql_mutex_unlock(&granted_thd->LOCK_wsrep_thd);
ret = TRUE;
}
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;
@@ -1261,6 +1289,7 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
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;
@@ -1268,6 +1297,7 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
else
{
WSREP_MDL_LOG(DEBUG, "MDL conflict-> BF abort", request_thd, granted_thd);
+ 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;
diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h
index d1c72e6001f..6b9640cea70 100644
--- a/sql/wsrep_mysqld.h
+++ b/sql/wsrep_mysqld.h
@@ -167,7 +167,7 @@ extern bool wsrep_sst_donor_update UPDATE_ARGS;
extern bool wsrep_slave_threads_check CHECK_ARGS;
extern bool wsrep_slave_threads_update UPDATE_ARGS;
-extern bool wsrep_init_first(); // initialize wsrep before storage
+extern bool wsrep_before_SE(); // initialize wsrep before storage
// engines (true) or after (false)
extern int wsrep_init();
extern void wsrep_deinit();
@@ -206,8 +206,8 @@ extern "C" void wsrep_thd_awake(THD *thd, my_bool signal);
/* wsrep initialization sequence at startup
- * @param first wsrep_init_first() value */
-extern void wsrep_init_startup(bool first);
+ * @param first wsrep_before_SE() value */
+extern void wsrep_init_startup(bool before);
extern void wsrep_close_client_connections(my_bool wait_to_end);
extern int wsrep_wait_committing_connections_close(int wait_time);
@@ -258,11 +258,11 @@ extern wsrep_seqno_t wsrep_locked_seqno;
#define WSREP_LOG_CONFLICT_THD(thd, role) \
WSREP_LOG(sql_print_information, \
"%s: \n " \
- " THD: %lu, mode: %s, state: %s, conflict: %s, seqno: %ld\n " \
+ " THD: %lu, mode: %s, state: %s, conflict: %s, seqno: %lld\n " \
" SQL: %s", \
role, wsrep_thd_thread_id(thd), wsrep_thd_exec_mode_str(thd), \
wsrep_thd_query_state_str(thd), \
- wsrep_thd_conflict_state_str(thd), wsrep_thd_trx_seqno(thd), \
+ wsrep_thd_conflict_state_str(thd), (long long)wsrep_thd_trx_seqno(thd), \
wsrep_thd_query(thd) \
);
diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc
index 53e3bbcfc79..597d0ea087d 100644
--- a/sql/wsrep_sst.cc
+++ b/sql/wsrep_sst.cc
@@ -164,10 +164,10 @@ bool wsrep_sst_donor_update (sys_var *self, THD* thd, enum_var_type type)
static wsrep_uuid_t cluster_uuid = WSREP_UUID_UNDEFINED;
-bool wsrep_init_first()
+bool wsrep_before_SE()
{
return (wsrep_provider != NULL
- && strcmp (wsrep_provider, WSREP_NONE)
+ && strcmp (wsrep_provider, WSREP_NONE)
&& strcmp (wsrep_sst_method, WSREP_SST_SKIP)
&& strcmp (wsrep_sst_method, WSREP_SST_MYSQLDUMP));
}
diff --git a/sql/wsrep_utils.cc b/sql/wsrep_utils.cc
index b1bd6de07cf..daba0e4cab2 100644
--- a/sql/wsrep_utils.cc
+++ b/sql/wsrep_utils.cc
@@ -354,8 +354,9 @@ size_t guess_ip (char* buf, size_t buf_len)
// try to find the address of the first one
#if (TARGET_OS_LINUX == 1)
const char cmd[] = "/sbin/ifconfig | "
- "grep -m1 -1 -E '^[a-z]?eth[0-9]' | tail -n 1 | "
- "awk '{ print $2 }' | awk -F : '{ print $2 }'";
+// "grep -m1 -1 -E '^[a-z]?eth[0-9]' | tail -n 1 | "
+ "grep -E '^[[:space:]]+inet addr:' | grep -m1 -v 'inet addr:127' | "
+ "sed 's/:/ /' | awk '{ print $3 }'";
#elif defined(__sun__)
const char cmd[] = "/sbin/ifconfig -a | "
"/usr/gnu/bin/grep -m1 -1 -E 'net[0-9]:' | tail -n 1 | awk '{ print $2 }'";
diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc
index 3136f905109..01f91b0a5ae 100644
--- a/sql/wsrep_var.cc
+++ b/sql/wsrep_var.cc
@@ -24,21 +24,28 @@
#include <cstdlib>
#define WSREP_START_POSITION_ZERO "00000000-0000-0000-0000-000000000000:-1"
-
-// trx history position to start with
-const char* wsrep_start_position = WSREP_START_POSITION_ZERO;
-const char* wsrep_provider = WSREP_NONE;
-const char* wsrep_provider_options = (const char*)my_memdup("", 1, MYF(MY_WME));
-const char* wsrep_cluster_address = NULL;
-const char* wsrep_cluster_name = "my_wsrep_cluster";
-const char* wsrep_node_name = glob_hostname;
-static char node_address[256] = { 0, };
-const char* wsrep_node_address = node_address;
+#define WSREP_CLUSTER_NAME "my_wsrep_cluster"
+
+const char* wsrep_provider = 0;
+const char* wsrep_provider_options = 0;
+const char* wsrep_cluster_address = 0;
+const char* wsrep_cluster_name = 0;
+const char* wsrep_node_name = 0;
+static char node_address[256] = { 0, };
+const char* wsrep_node_address = node_address; // ???
+const char* wsrep_start_position = 0;
ulong wsrep_OSU_method_options;
static int wsrep_thread_change = 0;
int wsrep_init_vars()
{
+ wsrep_provider = my_strdup(WSREP_NONE, MYF(MY_WME));
+ wsrep_provider_options= my_strdup("", MYF(MY_WME));
+ wsrep_cluster_address = my_strdup("", MYF(MY_WME));
+ wsrep_cluster_name = my_strdup(WSREP_CLUSTER_NAME, MYF(MY_WME));
+ wsrep_node_name = my_strdup("", MYF(MY_WME));
+ wsrep_start_position = my_strdup(WSREP_START_POSITION_ZERO, MYF(MY_WME));
+
global_system_variables.binlog_format=BINLOG_FORMAT_ROW;
return 0;
}
@@ -152,13 +159,13 @@ void wsrep_start_position_init (const char* val)
return;
}
- wsrep_start_position = my_strdup(val, MYF(0));
-
wsrep_set_local_position (val);
}
static bool refresh_provider_options()
{
+ WSREP_DEBUG("refresh_provider_options: %s",
+ (wsrep_provider_options) ? wsrep_provider_options : "null");
char* opts= wsrep->options_get(wsrep);
if (opts)
{
@@ -225,6 +232,8 @@ bool wsrep_provider_update (sys_var *self, THD* thd, enum_var_type type)
bool wsrep_on_saved= thd->variables.wsrep_on;
thd->variables.wsrep_on= false;
+ WSREP_DEBUG("wsrep_provider_update: %s", wsrep_provider);
+
wsrep_stop_replication(thd);
wsrep_deinit();
@@ -250,12 +259,17 @@ bool wsrep_provider_update (sys_var *self, THD* thd, enum_var_type type)
void wsrep_provider_init (const char* value)
{
+ WSREP_DEBUG("wsrep_provider_init: %s -> %s",
+ (wsrep_provider) ? wsrep_provider : "null",
+ (value) ? value : "null");
if (NULL == value || wsrep_provider_verify (value))
{
WSREP_ERROR("Bad initial value for wsrep_provider: %s",
(value ? value : ""));
return;
}
+
+ if (wsrep_provider) my_free((void *)wsrep_provider);
wsrep_provider = my_strdup(value, MYF(0));
}
@@ -327,9 +341,11 @@ bool wsrep_cluster_address_update (sys_var *self, THD* thd, enum_var_type type)
void wsrep_cluster_address_init (const char* value)
{
- if (wsrep_cluster_address && wsrep_cluster_address != value)
- my_free ((void*)wsrep_cluster_address);
-
+ WSREP_DEBUG("wsrep_cluster_address_init: %s -> %s",
+ (wsrep_cluster_address) ? wsrep_cluster_address : "null",
+ (value) ? value : "null");
+
+ if (wsrep_cluster_address) my_free ((void*)wsrep_cluster_address);
wsrep_cluster_address = (value) ? my_strdup(value, MYF(0)) : NULL;
}