Commit 8c7ef99b authored by Jan Lindström's avatar Jan Lindström

MDEV-7100: InnoDB error monitor might unnecessary wait log_sys mutex

Analysis: InnoDB error monitor is responsible to call every second
sync_arr_wake_threads_if_sema_free() to wake up possible hanging 
threads if they are missed in mutex_signal_object. This is not 
possible if error monitor itself is on mutex/semaphore wait. We 
should avoid all unnecessary mutex/semaphore waits on error monitor.
Currently error monitor calls function buf_flush_stat_update() 
that calls log_get_lsn() function and there we will try to get 
log_sys mutex. Better, solution for error monitor is that in 
buf_flush_stat_update() we will try to get lsn with 
mutex_enter_nowait() and if we did not get mutex do not update 
the stats.

Fix: Use log_get_lsn_nowait() function on buf_flush_stat_update()
function. If returned lsn is 0, we do not update flush stats. 
log_get_lsn_nowait() will use mutex_enter_nowait() and if
we get mutex we return a correct lsn if not we return 0.
parent 356451fc
......@@ -2103,7 +2103,15 @@ buf_flush_stat_update(void)
ib_uint64_t lsn;
ulint n_flushed;
lsn = log_get_lsn();
lsn = log_get_lsn_nowait();
/* log_get_lsn_nowait tries to get log_sys->mutex with
mutex_enter_nowait, if this does not succeed function
returns 0, do not use that value to update stats. */
if (lsn == 0) {
return;
}
if (buf_flush_stat_cur.redo == 0) {
/* First time around. Just update the current LSN
and return. */
......
......@@ -419,14 +419,14 @@ lsn_t
log_get_lsn_nowait(void)
/*=============*/
{
lsn_t lsn;
lsn_t lsn=0;
if (mutex_enter_nowait(&(log_sys->mutex)))
return 0;
if (!mutex_enter_nowait(&(log_sys->mutex))) {
lsn = log_sys->lsn;
mutex_exit(&(log_sys->mutex));
}
return(lsn);
}
......
......@@ -2214,7 +2214,15 @@ buf_flush_stat_update(void)
ib_uint64_t lsn;
ulint n_flushed;
lsn = log_get_lsn();
lsn = log_get_lsn_nowait();
/* log_get_lsn_nowait tries to get log_sys->mutex with
mutex_enter_nowait, if this does not succeed function
returns 0, do not use that value to update stats. */
if (lsn == 0) {
return;
}
if (buf_flush_stat_cur.redo == 0) {
/* First time around. Just update the current LSN
and return. */
......
......@@ -434,14 +434,14 @@ lsn_t
log_get_lsn_nowait(void)
/*=============*/
{
lsn_t lsn;
lsn_t lsn=0;
if (mutex_enter_nowait(&(log_sys->mutex)))
return 0;
if (!mutex_enter_nowait(&(log_sys->mutex))) {
lsn = log_sys->lsn;
mutex_exit(&(log_sys->mutex));
}
return(lsn);
}
......
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