Commit 248dd65f authored by Sunny Bains's avatar Sunny Bains

Fix bug introduced by r3038. When a transaction is rolled back by the

lock monitor thread, it may have locks that are granted to waited to
waiting transactions. These waiting transactions will need to be woken
up but their trx->lock_wait_timeout flag will be FALSE causing the old
code to break. What we need is a flag that covers the entire lock
release process not individual transactions. The fix is to move the
flag out of trx_t and into srv_sys_t.
parent e2a3bb5a
......@@ -647,16 +647,6 @@ 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;
......
......@@ -720,6 +720,14 @@ struct srv_sys_struct{
in the waiting_threads array */
ulint activity_count; /*!< For tracking server
activity */
unsigned lock_wait_timeout; /*!< TRUE if the lock monitor
thread is rolling back a
transaction that has waited
for too long for the lock a
be granted. We use this flag
to track whether the
srv_sys->mutex needs to be
acquired or not */
};
UNIV_INTERN os_event_t srv_lock_timeout_thread_event;
......@@ -1773,7 +1781,7 @@ srv_release_mysql_thread_if_suspended(
{
ut_ad(mutex_own(&kernel_mutex));
if (!thr_get_trx(thr)->lock_wait_timeout) {
if (!srv_sys->lock_wait_timeout) {
srv_sys_mutex_enter();
} else {
ut_ad(srv_sys_mutex_own());
......@@ -1784,7 +1792,7 @@ srv_release_mysql_thread_if_suspended(
os_event_set(thr->slot->event);
}
if (!thr_get_trx(thr)->lock_wait_timeout) {
if (!srv_sys->lock_wait_timeout) {
srv_sys_mutex_exit();
}
}
......@@ -2327,13 +2335,14 @@ srv_lock_check_wait(
&& ut_dulint_cmp(trx->id, slot_trx->id) == 0
&& trx->wait_lock != NULL) {
ut_a(!srv_sys->lock_wait_timeout);
ut_a(trx->que_state == TRX_QUE_LOCK_WAIT);
trx->lock_wait_timeout = TRUE;
srv_sys->lock_wait_timeout = TRUE;
lock_cancel_waiting_and_release(trx->wait_lock);
trx->lock_wait_timeout = FALSE;
srv_sys->lock_wait_timeout = FALSE;
}
mutex_exit(&kernel_mutex);
......
......@@ -189,8 +189,6 @@ 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