From 7d69d4553403178478d7e97294ad745718f30960 Mon Sep 17 00:00:00 2001 From: marko <> Date: Fri, 8 Aug 2008 13:01:02 +0000 Subject: [PATCH] branches/zip: buf_LRU_free_block(): When buf_page_is_old(b), we incremented buf_pool->LRU_old_len. However, we forgot to check if buf_pool->LRU_old happens to point to b's successor in the LRU list. If it does, we must assign buf_pool->LRU_old = b. The following invariants hold: In the LRU list, the "old" flag should grow monotonically, i.e., it is 0 for the first few items and 1 from thereafter. If buf_pool->LRU_old != NULL, it must point to the first item with old=1 in the LRU list, and there must be buf_pool->LRU_old_len old items in the list. This should fix Mantis issue#50 and issue#68. --- buf/buf0lru.c | 6 ++++++ include/buf0buf.h | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) 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 */