Commit 7b26e187 authored by Sunny Bains's avatar Sunny Bains

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.
parent 83f422fe
......@@ -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);
}
......
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