summaryrefslogtreecommitdiff
path: root/sql/wsrep_mysqld.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/wsrep_mysqld.cc')
-rw-r--r--sql/wsrep_mysqld.cc96
1 files changed, 59 insertions, 37 deletions
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index 0158a78a10b..90b1c132ae9 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -922,19 +922,10 @@ bool wsrep_start_replication()
wsrep_sst_donor,
bootstrap)))
{
- if (-ESOCKTNOSUPPORT == rcode)
- {
- DBUG_PRINT("wsrep",("unrecognized cluster address: '%s', rcode: %d",
- wsrep_cluster_address, rcode));
- WSREP_ERROR("unrecognized cluster address: '%s', rcode: %d",
- wsrep_cluster_address, rcode);
- }
- else
- {
- DBUG_PRINT("wsrep",("wsrep->connect() failed: %d", rcode));
- WSREP_ERROR("wsrep::connect() failed: %d", rcode);
- }
-
+ DBUG_PRINT("wsrep",("wsrep->connect(%s) failed: %d",
+ wsrep_cluster_address, rcode));
+ WSREP_ERROR("wsrep::connect(%s) failed: %d",
+ wsrep_cluster_address, rcode);
return false;
}
else
@@ -1277,7 +1268,8 @@ int wsrep_alter_event_query(THD *thd, uchar** buf, size_t* buf_len)
if (wsrep_alter_query_string(thd, &log_query))
{
- WSREP_WARN("events alter string failed: %s", thd->query());
+ WSREP_WARN("events alter string failed: schema: %s, query: %s",
+ (thd->db ? thd->db : "(null)"), thd->query());
return 1;
}
return wsrep_to_buf_helper(thd, log_query.ptr(), log_query.length(), buf, buf_len);
@@ -1425,9 +1417,11 @@ static int wsrep_TOI_begin(THD *thd, char *db_, char *table_,
}
else if (key_arr.keys_len > 0) {
/* jump to error handler in mysql_execute_command() */
- WSREP_WARN("TO isolation failed for: %d, sql: %s. Check wsrep "
+ WSREP_WARN("TO isolation failed for: %d, schema: %s, sql: %s. Check wsrep "
"connection state and retry the query.",
- ret, (thd->query()) ? thd->query() : "void");
+ ret,
+ (thd->db ? thd->db : "(null)"),
+ (thd->query()) ? thd->query() : "void");
my_error(ER_LOCK_DEADLOCK, MYF(0), "WSREP replication failed. Check "
"your wsrep connection state and retry the query.");
wsrep_keys_free(&key_arr);
@@ -1460,8 +1454,10 @@ static void wsrep_TOI_end(THD *thd) {
WSREP_DEBUG("TO END: %lld", (long long)wsrep_thd_trx_seqno(thd));
}
else {
- WSREP_WARN("TO isolation end failed for: %d, sql: %s",
- ret, (thd->query()) ? thd->query() : "void");
+ WSREP_WARN("TO isolation end failed for: %d, schema: %s, sql: %s",
+ ret,
+ (thd->db ? thd->db : "(null)"),
+ (thd->query()) ? thd->query() : "void");
}
}
@@ -1474,7 +1470,10 @@ static int wsrep_RSU_begin(THD *thd, char *db_, char *table_)
ret = wsrep->desync(wsrep);
if (ret != WSREP_OK)
{
- WSREP_WARN("RSU desync failed %d for %s", ret, thd->query());
+ WSREP_WARN("RSU desync failed %d for schema: %s, query: %s",
+ ret,
+ (thd->db ? thd->db : "(null)"),
+ thd->query());
my_error(ER_LOCK_DEADLOCK, MYF(0));
return(ret);
}
@@ -1485,7 +1484,9 @@ static int wsrep_RSU_begin(THD *thd, char *db_, char *table_)
if (wsrep_wait_committing_connections_close(5000))
{
/* no can do, bail out from DDL */
- WSREP_WARN("RSU failed due to pending transactions, %s", thd->query());
+ WSREP_WARN("RSU failed due to pending transactions, schema: %s, query %s",
+ (thd->db ? thd->db : "(null)"),
+ thd->query());
mysql_mutex_lock(&LOCK_wsrep_replaying);
wsrep_replaying--;
mysql_mutex_unlock(&LOCK_wsrep_replaying);
@@ -1493,7 +1494,10 @@ static int wsrep_RSU_begin(THD *thd, char *db_, char *table_)
ret = wsrep->resync(wsrep);
if (ret != WSREP_OK)
{
- WSREP_WARN("resync failed %d for %s", ret, thd->query());
+ WSREP_WARN("resync failed %d for schema: %s, query: %s",
+ ret,
+ (thd->db ? thd->db : "(null)"),
+ thd->query());
}
my_error(ER_LOCK_DEADLOCK, MYF(0));
return(1);
@@ -1502,7 +1506,9 @@ static int wsrep_RSU_begin(THD *thd, char *db_, char *table_)
wsrep_seqno_t seqno = wsrep->pause(wsrep);
if (seqno == WSREP_SEQNO_UNDEFINED)
{
- WSREP_WARN("pause failed %lld for %s", (long long)seqno, thd->query());
+ WSREP_WARN("pause failed %lld for schema: %s, query: %s", (long long)seqno,
+ (thd->db ? thd->db : "(null)"),
+ thd->query());
return(1);
}
WSREP_DEBUG("paused at %lld", (long long)seqno);
@@ -1524,12 +1530,16 @@ static void wsrep_RSU_end(THD *thd)
ret = wsrep->resume(wsrep);
if (ret != WSREP_OK)
{
- WSREP_WARN("resume failed %d for %s", ret, thd->query());
+ WSREP_WARN("resume failed %d for schema: %s, query: %s", ret,
+ (thd->db ? thd->db : "(null)"),
+ thd->query());
}
ret = wsrep->resync(wsrep);
if (ret != WSREP_OK)
{
- WSREP_WARN("resync failed %d for %s", ret, thd->query());
+ WSREP_WARN("resync failed %d for schema: %s, query: %s", ret,
+ (thd->db ? thd->db : "(null)"),
+ thd->query());
return;
}
thd->variables.wsrep_on = 1;
@@ -1550,8 +1560,10 @@ int wsrep_to_isolation_begin(THD *thd, char *db_, char *table_,
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());
+ WSREP_INFO("thread: %lu, schema: %s, query: %s has been aborted due to multi-master conflict",
+ thd->thread_id,
+ (thd->db ? thd->db : "(null)"),
+ thd->query());
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
return WSREP_TRX_FAIL;
}
@@ -1629,15 +1641,16 @@ void wsrep_to_isolation_end(THD *thd)
}
}
-#define WSREP_MDL_LOG(severity, msg, req, gra) \
+#define WSREP_MDL_LOG(severity, msg, schema, schema_len, req, gra) \
WSREP_##severity( \
"%s\n" \
+ "schema: %.*s\n" \
"request: (%lu \tseqno %lld \twsrep (%d, %d, %d) cmd %d %d \t%s)\n" \
"granted: (%lu \tseqno %lld \twsrep (%d, %d, %d) cmd %d %d \t%s)", \
- msg, \
+ msg, schema_len, schema, \
req->thread_id, (long long)wsrep_thd_trx_seqno(req), \
req->wsrep_exec_mode, req->wsrep_query_state, req->wsrep_conflict_state, \
- req->get_command(), req->lex->sql_command, req->query(), \
+ req->get_command(), req->lex->sql_command, req->query(), \
gra->thread_id, (long long)wsrep_thd_trx_seqno(gra), \
gra->wsrep_exec_mode, gra->wsrep_query_state, gra->wsrep_conflict_state, \
gra->get_command(), gra->lex->sql_command, gra->query());
@@ -1654,7 +1667,8 @@ void wsrep_to_isolation_end(THD *thd)
bool
wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
- MDL_ticket *ticket
+ MDL_ticket *ticket,
+ const MDL_key *key
) {
/* Fallback to the non-wsrep behaviour */
if (!WSREP_ON) return FALSE;
@@ -1663,29 +1677,35 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
THD *granted_thd = ticket->get_ctx()->get_thd();
bool ret = FALSE;
+ const char* schema= key->db_name();
+ int schema_len= key->db_name_length();
+
mysql_mutex_lock(&request_thd->LOCK_wsrep_thd);
if (request_thd->wsrep_exec_mode == TOTAL_ORDER ||
request_thd->wsrep_exec_mode == REPL_RECV)
{
mysql_mutex_unlock(&request_thd->LOCK_wsrep_thd);
- WSREP_MDL_LOG(DEBUG, "MDL conflict ", request_thd, granted_thd);
+ WSREP_MDL_LOG(DEBUG, "MDL conflict ", schema, schema_len,
+ 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);
+ WSREP_MDL_LOG(INFO, "MDL BF-BF conflict", schema, schema_len,
+ 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)
+ else if (granted_thd->lex->sql_command == SQLCOM_FLUSH ||
+ granted_thd->mdl_context.has_explicit_locks())
{
- WSREP_DEBUG("MDL granted over FLUSH BF");
+ WSREP_DEBUG("BF thread waiting for FLUSH");
ticket->wsrep_report(wsrep_debug);
mysql_mutex_unlock(&granted_thd->LOCK_wsrep_thd);
- ret = TRUE;
+ ret = FALSE;
}
else if (request_thd->lex->sql_command == SQLCOM_DROP_TABLE)
{
@@ -1705,7 +1725,8 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
}
else
{
- WSREP_MDL_LOG(DEBUG, "MDL conflict-> BF abort", request_thd, granted_thd);
+ WSREP_MDL_LOG(DEBUG, "MDL conflict-> BF abort", schema, schema_len,
+ 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);
@@ -2177,7 +2198,8 @@ int wsrep_create_sp(THD *thd, uchar** buf, size_t* buf_len)
&(thd->lex->definer->host),
saved_mode))
{
- WSREP_WARN("SP create string failed: %s", thd->query());
+ WSREP_WARN("SP create string failed: schema: %s, query: %s",
+ (thd->db ? thd->db : "(null)"), thd->query());
return 1;
}