diff options
author | Philip Stoev <philip.stoev@galeracluster.com> | 2015-10-19 01:56:04 -0700 |
---|---|---|
committer | Philip Stoev <philip.stoev@galeracluster.com> | 2015-10-19 01:56:04 -0700 |
commit | 43b2a451fe62e7a1172fa3d611039b3d11c1dd36 (patch) | |
tree | a87a75a184a534014706d57ad693850ee9840d8b /sql/wsrep_mysqld.cc | |
parent | 4d33f9dca027e1f66f9898146533e8c1d612f2d1 (diff) | |
download | mariadb-git-43b2a451fe62e7a1172fa3d611039b3d11c1dd36.tar.gz |
refs codership/mysql-wsrep#202 Added schema info into wsrep messages
Added schema info to wsrep messages above debug level.
Diffstat (limited to 'sql/wsrep_mysqld.cc')
-rw-r--r-- | sql/wsrep_mysqld.cc | 65 |
1 files changed, 46 insertions, 19 deletions
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index b05214682e6..a9cdb5b5b11 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -1253,9 +1253,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); @@ -1288,8 +1290,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"); } } @@ -1302,7 +1306,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); } @@ -1313,7 +1320,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); @@ -1321,7 +1330,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); @@ -1330,7 +1342,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); @@ -1352,12 +1366,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; @@ -1377,8 +1395,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; } @@ -1456,12 +1476,12 @@ 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(), \ @@ -1481,7 +1501,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; @@ -1490,19 +1511,24 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx, THD *granted_thd = ticket->get_ctx()->wsrep_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; @@ -1533,7 +1559,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); |