Commit fe9f2f4b authored by Jan Lindström's avatar Jan Lindström

MDEV-16401: Apply review comments to MDEV-16005

Do not hold LOCK_thd_data during my_error or WSREP_DEBUG. Similarly,
release LOCK_thd_data before close_thread_tables() call.
parent b75d8196
......@@ -1271,9 +1271,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (thd->wsrep_conflict_state == ABORTED &&
command != COM_STMT_CLOSE && command != COM_QUIT)
{
mysql_mutex_unlock(&thd->LOCK_thd_data);
my_error(ER_LOCK_DEADLOCK, MYF(0), "wsrep aborted transaction");
WSREP_DEBUG("Deadlock error for: %s", thd->query());
mysql_mutex_unlock(&thd->LOCK_thd_data);
thd->reset_killed();
thd->mysys_var->abort = 0;
thd->wsrep_conflict_state = NO_CONFLICT;
......@@ -7290,6 +7290,7 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
thd->lex->sql_command != SQLCOM_SELECT &&
(thd->wsrep_retry_counter < thd->variables.wsrep_retry_autocommit))
{
mysql_mutex_unlock(&thd->LOCK_thd_data);
WSREP_DEBUG("wsrep retrying AC query: %s",
(thd->query()) ? thd->query() : "void");
......@@ -7297,27 +7298,36 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
MYSQL_END_STATEMENT(thd->m_statement_psi, thd->get_stmt_da());
thd->m_statement_psi= NULL;
thd->m_digest= NULL;
// Released thd->LOCK_thd_data above as below could end up
// close_thread_tables()/close_open_tables()/close_thread_table()/mysql_mutex_lock(&thd->LOCK_thd_data)
close_thread_tables(thd);
mysql_mutex_lock(&thd->LOCK_thd_data);
thd->wsrep_conflict_state= RETRY_AUTOCOMMIT;
thd->wsrep_retry_counter++; // grow
wsrep_copy_query(thd);
thd->set_time();
parser_state->reset(rawbuf, length);
mysql_mutex_unlock(&thd->LOCK_thd_data);
}
else
{
mysql_mutex_unlock(&thd->LOCK_thd_data);
// This does dirty read to wsrep variables but it is only a debug code
WSREP_DEBUG("%s, thd: %lu is_AC: %d, retry: %lu - %lu SQL: %s",
(thd->wsrep_conflict_state == ABORTED) ?
"BF Aborted" : "cert failure",
thd->thread_id, is_autocommit, thd->wsrep_retry_counter,
thd->variables.wsrep_retry_autocommit, thd->query());
my_error(ER_LOCK_DEADLOCK, MYF(0), "wsrep aborted transaction");
mysql_mutex_lock(&thd->LOCK_thd_data);
thd->wsrep_conflict_state= NO_CONFLICT;
if (thd->wsrep_conflict_state != REPLAYING)
thd->wsrep_retry_counter= 0; // reset
}
mysql_mutex_unlock(&thd->LOCK_thd_data);
}
thd->reset_killed();
}
else
......@@ -7353,6 +7363,7 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
#endif /* WITH_WSREP */
}
/*
When you modify mysql_parse(), you may need to modify
mysql_test_parse_for_slave() in this same file.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment