mirror of
https://github.com/MariaDB/server.git
synced 2025-12-12 08:01:43 +03:00
branches/zip: buf_LRU_free_block(): New function, split from
buf_LRU_search_and_free_block().
This commit is contained in:
@@ -116,7 +116,7 @@ buf_flush_ready_for_replace(
|
|||||||
ut_ad(mutex_own(&(buf_pool->mutex)));
|
ut_ad(mutex_own(&(buf_pool->mutex)));
|
||||||
ut_ad(mutex_own(&block->mutex));
|
ut_ad(mutex_own(&block->mutex));
|
||||||
#endif /* UNIV_SYNC_DEBUG */
|
#endif /* UNIV_SYNC_DEBUG */
|
||||||
if (block->state != BUF_BLOCK_FILE_PAGE) {
|
if (UNIV_UNLIKELY(block->state != BUF_BLOCK_FILE_PAGE)) {
|
||||||
ut_print_timestamp(stderr);
|
ut_print_timestamp(stderr);
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
" InnoDB: Error: buffer block state %lu"
|
" InnoDB: Error: buffer block state %lu"
|
||||||
|
|||||||
@@ -193,6 +193,53 @@ buf_LRU_get_recent_limit(void)
|
|||||||
return(limit);
|
return(limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
Try to free a block. */
|
||||||
|
|
||||||
|
ibool
|
||||||
|
buf_LRU_free_block(
|
||||||
|
/*===============*/
|
||||||
|
/* out: TRUE if freed */
|
||||||
|
buf_block_t* block) /* in: block to be freed */
|
||||||
|
{
|
||||||
|
#ifdef UNIV_SYNC_DEBUG
|
||||||
|
ut_ad(mutex_own(&buf_pool->mutex));
|
||||||
|
ut_ad(mutex_own(&block->mutex));
|
||||||
|
#endif /* UNIV_SYNC_DEBUG */
|
||||||
|
|
||||||
|
ut_a(block->in_LRU_list);
|
||||||
|
|
||||||
|
if (!buf_flush_ready_for_replace(block)) {
|
||||||
|
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef UNIV_DEBUG
|
||||||
|
if (buf_debug_prints) {
|
||||||
|
fprintf(stderr, "Putting space %lu page %lu to free list\n",
|
||||||
|
(ulong) block->space, (ulong) block->offset);
|
||||||
|
}
|
||||||
|
#endif /* UNIV_DEBUG */
|
||||||
|
|
||||||
|
buf_LRU_block_remove_hashed_page(block);
|
||||||
|
|
||||||
|
mutex_exit(&(buf_pool->mutex));
|
||||||
|
mutex_exit(&block->mutex);
|
||||||
|
|
||||||
|
/* Remove possible adaptive hash index on the page */
|
||||||
|
|
||||||
|
btr_search_drop_page_hash_index(block);
|
||||||
|
|
||||||
|
ut_a(block->buf_fix_count == 0);
|
||||||
|
|
||||||
|
mutex_enter(&(buf_pool->mutex));
|
||||||
|
mutex_enter(&block->mutex);
|
||||||
|
|
||||||
|
buf_LRU_block_free_hashed_page(block);
|
||||||
|
|
||||||
|
return(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
Look for a replaceable block from the end of the LRU list and put it to
|
Look for a replaceable block from the end of the LRU list and put it to
|
||||||
the free list if found. */
|
the free list if found. */
|
||||||
@@ -218,62 +265,30 @@ buf_LRU_search_and_free_block(
|
|||||||
block = UT_LIST_GET_LAST(buf_pool->LRU);
|
block = UT_LIST_GET_LAST(buf_pool->LRU);
|
||||||
|
|
||||||
while (block != NULL) {
|
while (block != NULL) {
|
||||||
ut_a(block->in_LRU_list);
|
|
||||||
|
|
||||||
mutex_enter(&block->mutex);
|
mutex_enter(&block->mutex);
|
||||||
|
freed = buf_LRU_free_block(block);
|
||||||
|
mutex_exit(&block->mutex);
|
||||||
|
|
||||||
if (buf_flush_ready_for_replace(block)) {
|
if (freed) {
|
||||||
|
|
||||||
#ifdef UNIV_DEBUG
|
|
||||||
if (buf_debug_prints) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"Putting space %lu page %lu"
|
|
||||||
" to free list\n",
|
|
||||||
(ulong) block->space,
|
|
||||||
(ulong) block->offset);
|
|
||||||
}
|
|
||||||
#endif /* UNIV_DEBUG */
|
|
||||||
|
|
||||||
buf_LRU_block_remove_hashed_page(block);
|
|
||||||
|
|
||||||
mutex_exit(&(buf_pool->mutex));
|
|
||||||
mutex_exit(&block->mutex);
|
|
||||||
|
|
||||||
/* Remove possible adaptive hash index on the page */
|
|
||||||
|
|
||||||
btr_search_drop_page_hash_index(block);
|
|
||||||
|
|
||||||
|
|
||||||
ut_a(block->buf_fix_count == 0);
|
|
||||||
|
|
||||||
mutex_enter(&(buf_pool->mutex));
|
|
||||||
mutex_enter(&block->mutex);
|
|
||||||
|
|
||||||
buf_LRU_block_free_hashed_page(block);
|
|
||||||
freed = TRUE;
|
|
||||||
mutex_exit(&block->mutex);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_exit(&block->mutex);
|
|
||||||
|
|
||||||
block = UT_LIST_GET_PREV(LRU, block);
|
block = UT_LIST_GET_PREV(LRU, block);
|
||||||
distance++;
|
distance++;
|
||||||
|
|
||||||
if (!freed && n_iterations <= 10
|
if (n_iterations <= 10
|
||||||
&& distance > 100 + (n_iterations * buf_pool->curr_size)
|
&& distance > 100 + (n_iterations * buf_pool->curr_size)
|
||||||
/ 10) {
|
/ 10) {
|
||||||
buf_pool->LRU_flush_ended = 0;
|
goto func_exit;
|
||||||
|
|
||||||
mutex_exit(&(buf_pool->mutex));
|
|
||||||
|
|
||||||
return(FALSE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf_pool->LRU_flush_ended > 0) {
|
if (buf_pool->LRU_flush_ended > 0) {
|
||||||
buf_pool->LRU_flush_ended--;
|
buf_pool->LRU_flush_ended--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func_exit:
|
||||||
if (!freed) {
|
if (!freed) {
|
||||||
buf_pool->LRU_flush_ended = 0;
|
buf_pool->LRU_flush_ended = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,14 @@ buf_LRU_get_recent_limit(void);
|
|||||||
/*==========================*/
|
/*==========================*/
|
||||||
/* out: the limit; zero if could not determine it */
|
/* out: the limit; zero if could not determine it */
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
Try to free a block. */
|
||||||
|
|
||||||
|
ibool
|
||||||
|
buf_LRU_free_block(
|
||||||
|
/*===============*/
|
||||||
|
/* out: TRUE if freed */
|
||||||
|
buf_block_t* block); /* in: block to be freed */
|
||||||
|
/**********************************************************************
|
||||||
Look for a replaceable block from the end of the LRU list and put it to
|
Look for a replaceable block from the end of the LRU list and put it to
|
||||||
the free list if found. */
|
the free list if found. */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user