diff --git a/buf/buf0lru.c b/buf/buf0lru.c index 7922e885671..576a6c9f319 100644 --- a/buf/buf0lru.c +++ b/buf/buf0lru.c @@ -1246,6 +1246,12 @@ alloc: if (buf_page_is_old(b)) { buf_pool->LRU_old_len++; + if (UNIV_UNLIKELY + (buf_pool->LRU_old + == UT_LIST_GET_NEXT(LRU, b))) { + + buf_pool->LRU_old = b; + } } lru_len = UT_LIST_GET_LEN(buf_pool->LRU); diff --git a/include/buf0buf.h b/include/buf0buf.h index afdf6c353f8..84337fef54a 100644 --- a/include/buf0buf.h +++ b/include/buf0buf.h @@ -1277,13 +1277,17 @@ struct buf_pool_struct{ /* base node of the LRU list */ buf_page_t* LRU_old; /* pointer to the about 3/8 oldest blocks in the LRU list; NULL if LRU - length less than BUF_LRU_OLD_MIN_LEN */ + length less than BUF_LRU_OLD_MIN_LEN; + NOTE: when LRU_old != NULL, its length + should always equal LRU_old_len */ ulint LRU_old_len; /* length of the LRU list from the block to which LRU_old points onward, including that block; see buf0lru.c for the restrictions on this value; not defined if - LRU_old == NULL */ + LRU_old == NULL; + NOTE: LRU_old_len must be adjusted + whenever LRU_old shrinks or grows! */ UT_LIST_BASE_NODE_T(buf_block_t) unzip_LRU; /* base node of the unzip_LRU list */