Commit a3ba3aab authored by Daniele Sciascia's avatar Daniele Sciascia

MDEV-13549 Wrong usage of mutex 'LOCK_wsrep_thd' and 'LOCK_thd_kill' test galera.MW-286

Test MW-286 occasionally failed with error the following message:

```
safe_mutex: Found wrong usage of mutex 'LOCK_wsrep_thd' and 'LOCK_thd_kill'
Mutex currently locked (in reverse order):
LOCK_thd_kill                     mariadb-server/sql/sql_class.h  line 3535
LOCK_wsrep_thd                    mariadb-server/sql/wsrep_thd.cc  line 88
```

The fix consists in calling thd->reset_killed() in wsrep_mysql_parse() after
LOCK_wsrep_thd is unlocked. Which avoids the taking locks LOCK_wsrep_thd and
LOCK_thd_kill in reverse order.
parent 0f0776b2
...@@ -7193,7 +7193,6 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length, ...@@ -7193,7 +7193,6 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
thd->wsrep_conflict_state == CERT_FAILURE) thd->wsrep_conflict_state == CERT_FAILURE)
{ {
thd->reset_for_next_command(); thd->reset_for_next_command();
thd->reset_killed();
if (is_autocommit && if (is_autocommit &&
thd->lex->sql_command != SQLCOM_SELECT && thd->lex->sql_command != SQLCOM_SELECT &&
(thd->wsrep_retry_counter < thd->variables.wsrep_retry_autocommit)) (thd->wsrep_retry_counter < thd->variables.wsrep_retry_autocommit))
...@@ -7221,18 +7220,19 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length, ...@@ -7221,18 +7220,19 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
thd->thread_id, is_autocommit, thd->wsrep_retry_counter, thd->thread_id, is_autocommit, thd->wsrep_retry_counter,
thd->variables.wsrep_retry_autocommit, thd->query()); thd->variables.wsrep_retry_autocommit, thd->query());
my_error(ER_LOCK_DEADLOCK, MYF(0), "wsrep aborted transaction"); my_error(ER_LOCK_DEADLOCK, MYF(0), "wsrep aborted transaction");
thd->reset_killed();
thd->wsrep_conflict_state= NO_CONFLICT; thd->wsrep_conflict_state= NO_CONFLICT;
if (thd->wsrep_conflict_state != REPLAYING) if (thd->wsrep_conflict_state != REPLAYING)
thd->wsrep_retry_counter= 0; // reset thd->wsrep_retry_counter= 0; // reset
} }
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
thd->reset_killed();
} }
else else
{ {
set_if_smaller(thd->wsrep_retry_counter, 0); // reset; eventually ok set_if_smaller(thd->wsrep_retry_counter, 0); // reset; eventually ok
}
mysql_mutex_unlock(&thd->LOCK_wsrep_thd); mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
} }
}
/* If retry is requested clean up explain structure */ /* If retry is requested clean up explain structure */
if (thd->wsrep_conflict_state == RETRY_AUTOCOMMIT && thd->lex->explain) if (thd->wsrep_conflict_state == RETRY_AUTOCOMMIT && thd->lex->explain)
......
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