mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 05:52:27 +01:00
Fix a race condition introduced by r7004. We need to acquire the srv_sys->mutex
for all other cases where we release a suspended thread waiting on a lock other than those released by the lock wait timer thread.
This commit is contained in:
parent
0e23387940
commit
7e094ea012
3 changed files with 26 additions and 4 deletions
|
@ -647,6 +647,16 @@ struct trx_struct{
|
|||
TRX_QUE_LOCK_WAIT, this points to
|
||||
the lock request, otherwise this is
|
||||
NULL */
|
||||
ibool lock_wait_timeout;
|
||||
/* when this transaction is rolled
|
||||
back because the lock wait timed out.
|
||||
We use this flag to distinguish between
|
||||
a wait time out detected by the lock
|
||||
monitor thread vs other code paths. For
|
||||
the former we already have the the
|
||||
srv_sys->mutex locked. For the other
|
||||
cases we need to acquire it explicitly
|
||||
when releasing a suspended thread. */
|
||||
ibool was_chosen_as_deadlock_victim;
|
||||
/* when the transaction decides to wait
|
||||
for a lock, it sets this to FALSE;
|
||||
|
|
|
@ -1773,11 +1773,18 @@ srv_release_mysql_thread_if_suspended(
|
|||
{
|
||||
ut_ad(mutex_own(&kernel_mutex));
|
||||
|
||||
if (thr->slot != NULL) {
|
||||
ut_a(thr->slot->in_use);
|
||||
if (!thr_get_trx(thr)->lock_wait_timeout) {
|
||||
srv_sys_mutex_enter();
|
||||
}
|
||||
|
||||
if (thr->slot != NULL && thr->slot->in_use && thr->slot->thr == thr) {
|
||||
|
||||
os_event_set(thr->slot->event);
|
||||
}
|
||||
|
||||
if (!thr_get_trx(thr)->lock_wait_timeout) {
|
||||
srv_sys_mutex_exit();
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************//**
|
||||
|
@ -2320,8 +2327,11 @@ srv_lock_check_wait(
|
|||
|
||||
ut_a(trx->que_state == TRX_QUE_LOCK_WAIT);
|
||||
|
||||
lock_cancel_waiting_and_release(
|
||||
trx->wait_lock);
|
||||
trx->lock_wait_timeout = TRUE;
|
||||
|
||||
lock_cancel_waiting_and_release(trx->wait_lock);
|
||||
|
||||
trx->lock_wait_timeout = FALSE;
|
||||
}
|
||||
|
||||
mutex_exit(&kernel_mutex);
|
||||
|
|
|
@ -189,6 +189,8 @@ trx_create(
|
|||
trx->autoinc_locks = ib_vector_create(
|
||||
mem_heap_create(sizeof(ib_vector_t) + sizeof(void*) * 4), 4);
|
||||
|
||||
trx->lock_wait_timeout = FALSE;
|
||||
|
||||
return(trx);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue