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 | |
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.
-rw-r--r-- | sql/events.cc | 6 | ||||
-rw-r--r-- | sql/mdl.cc | 8 | ||||
-rw-r--r-- | sql/mdl.h | 1 | ||||
-rw-r--r-- | sql/sp.cc | 3 | ||||
-rw-r--r-- | sql/wsrep_hton.cc | 18 | ||||
-rw-r--r-- | sql/wsrep_mysqld.cc | 65 | ||||
-rw-r--r-- | sql/wsrep_thd.cc | 6 | ||||
-rw-r--r-- | sql/wsrep_var.cc | 8 |
8 files changed, 79 insertions, 36 deletions
diff --git a/sql/events.cc b/sql/events.cc index 357695cdced..1feb285e3a0 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -1195,7 +1195,8 @@ int wsrep_create_event_query(THD *thd, uchar** buf, size_t* buf_len) if (create_query_string(thd, &log_query)) { - WSREP_WARN("events create string failed: %s", thd->query()); + WSREP_WARN("events create 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); @@ -1222,7 +1223,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); diff --git a/sql/mdl.cc b/sql/mdl.cc index 8c446e5d65f..44831c55b44 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -33,7 +33,8 @@ void sql_print_information(const char *format, ...) extern bool wsrep_grant_mdl_exception(MDL_context *requestor_ctx, - MDL_ticket *ticket); + MDL_ticket *ticket, + const MDL_key *key); #endif /* WITH_WSREP */ #ifdef HAVE_PSI_INTERFACE static PSI_mutex_key key_MDL_map_mutex; @@ -1549,7 +1550,8 @@ void MDL_lock::Ticket_list::add_ticket(MDL_ticket *ticket) if (granted->get_ctx() != ticket->get_ctx() && granted->is_incompatible_when_granted(ticket->get_type())) { - if (!wsrep_grant_mdl_exception(ticket->get_ctx(), granted)) + if (!wsrep_grant_mdl_exception(ticket->get_ctx(), granted, + &ticket->get_lock()->key)) { WSREP_DEBUG("MDL victim killed at add_ticket"); } @@ -1941,7 +1943,7 @@ MDL_lock::can_grant_lock(enum_mdl_type type_arg, wsrep_thd_query(requestor_ctx->wsrep_get_thd())); can_grant = true; } - else if (!wsrep_grant_mdl_exception(requestor_ctx, ticket)) + else if (!wsrep_grant_mdl_exception(requestor_ctx, ticket, &key)) { wsrep_can_grant= FALSE; if (wsrep_log_conflicts) diff --git a/sql/mdl.h b/sql/mdl.h index 0898a0f75b7..7fb303d4720 100644 --- a/sql/mdl.h +++ b/sql/mdl.h @@ -457,6 +457,7 @@ public: MDL_key key; public: + static void *operator new(size_t size, MEM_ROOT *mem_root) throw () { return alloc_root(mem_root, size); } static void operator delete(void *ptr, MEM_ROOT *mem_root) {} diff --git a/sql/sp.cc b/sql/sp.cc index c4cd847bc02..4a0e890e0cb 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -2302,7 +2302,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; } return wsrep_to_buf_helper(thd, log_query.ptr(), log_query.length(), buf, buf_len); diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc index 03bf072edcc..c096d2610eb 100644 --- a/sql/wsrep_hton.cc +++ b/sql/wsrep_hton.cc @@ -239,8 +239,9 @@ static int wsrep_rollback(handlerton *hton, THD *thd, bool all) if (WSREP(thd) && wsrep->post_rollback(wsrep, &thd->wsrep_ws_handle)) { DBUG_PRINT("wsrep", ("setting rollback fail")); - WSREP_ERROR("settting rollback fail: thd: %llu SQL: %s", - (long long)thd->real_id, thd->query()); + WSREP_ERROR("settting rollback fail: thd: %llu, schema: %s, SQL: %s", + (long long)thd->real_id, (thd->db ? thd->db : "(null)"), + thd->query()); } wsrep_cleanup_transaction(thd); } @@ -279,8 +280,9 @@ int wsrep_commit(handlerton *hton, THD *thd, bool all) if (WSREP(thd) && wsrep->post_rollback(wsrep, &thd->wsrep_ws_handle)) { DBUG_PRINT("wsrep", ("setting rollback fail")); - WSREP_ERROR("settting rollback fail: thd: %llu SQL: %s", - (long long)thd->real_id, thd->query()); + WSREP_ERROR("settting rollback fail: thd: %llu, schema: %s, SQL: %s", + (long long)thd->real_id, (thd->db ? thd->db : "(null)"), + thd->query()); } wsrep_cleanup_transaction(thd); } @@ -441,9 +443,11 @@ wsrep_run_wsrep_commit(THD *thd, handlerton *hton, bool all) if (WSREP_UNDEFINED_TRX_ID == thd->wsrep_ws_handle.trx_id) { WSREP_WARN("SQL statement was ineffective, THD: %lu, buf: %zu\n" + "schema: %s \n" "QUERY: %s\n" " => Skipping replication", - thd->thread_id, data_len, thd->query()); + thd->thread_id, data_len, + (thd->db ? thd->db : "(null)"), thd->query()); rcode = WSREP_TRX_FAIL; } else if (!rcode) @@ -458,8 +462,8 @@ wsrep_run_wsrep_commit(THD *thd, handlerton *hton, bool all) &thd->wsrep_trx_meta); if (rcode == WSREP_TRX_MISSING) { - WSREP_WARN("Transaction missing in provider, thd: %ld, SQL: %s", - thd->thread_id, thd->query()); + WSREP_WARN("Transaction missing in provider, thd: %ld, schema: %s, SQL: %s", + thd->thread_id, (thd->db ? thd->db : "(null)"), thd->query()); rcode = WSREP_TRX_FAIL; } else if (rcode == WSREP_BF_ABORT) { WSREP_DEBUG("thd %lu seqno %lld BF aborted by provider, will replay", 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); diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc index 776a640cabe..464a68a8221 100644 --- a/sql/wsrep_thd.cc +++ b/sql/wsrep_thd.cc @@ -274,8 +274,10 @@ void wsrep_replay_transaction(THD *thd) wsrep->post_rollback(wsrep, &thd->wsrep_ws_handle); break; default: - WSREP_ERROR("trx_replay failed for: %d, query: %s", - rcode, thd->query() ? thd->query() : "void"); + WSREP_ERROR("trx_replay failed for: %d, schema: %s, query: %s", + rcode, + (thd->db ? thd->db : "(null)"), + thd->query() ? thd->query() : "void"); /* we're now in inconsistent state, must abort */ /* http://bazaar.launchpad.net/~codership/codership-mysql/5.6/revision/3962#sql/wsrep_thd.cc */ diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index bbfa79ac3fd..a3366000fc5 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -512,14 +512,18 @@ bool wsrep_desync_update (sys_var *self, THD* thd, enum_var_type type) if (wsrep_desync) { ret = wsrep->desync (wsrep); if (ret != WSREP_OK) { - WSREP_WARN ("SET desync failed %d for %s", ret, thd->query()); + WSREP_WARN ("SET desync failed %d for schema: %s, query: %s", ret, + (thd->db ? thd->db : "(null)"), + thd->query()); my_error (ER_CANNOT_USER, MYF(0), "'desync'", thd->query()); return true; } } else { ret = wsrep->resync (wsrep); if (ret != WSREP_OK) { - WSREP_WARN ("SET resync failed %d for %s", ret, thd->query()); + WSREP_WARN ("SET resync failed %d for schema: %s, query: %s", ret, + (thd->db ? thd->db : "(null)"), + thd->query()); my_error (ER_CANNOT_USER, MYF(0), "'resync'", thd->query()); return true; } |