mirror of
https://github.com/MariaDB/server.git
synced 2025-08-09 22:24:09 +03:00
Merge pull request #104 from philip-galera/10.0-galera-mysql-wsrep-gh202
Refs codership/mysql-wsrep#202 Added schema info into wsrep messages
This commit is contained in:
@@ -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);
|
||||
|
@@ -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)
|
||||
|
@@ -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) {}
|
||||
|
@@ -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);
|
||||
|
@@ -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",
|
||||
|
@@ -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);
|
||||
|
@@ -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 */
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user