MDEV-37250 buf_pool_t::shrink() assertion failure

buf_pool_t::shrink(): When relocating a dirty page of the temporary
tablespace, reset the oldest_modification() on the discarded block,
like we do for persistent pages in buf_flush_relocate_on_flush_list().

buf_pool_t::resize(): Add debug assertions to catch this error earlier.

This bug does not seem to affect non-debug builds.

Reviewed by: Thirunarayanan Balathandayuthapani
This commit is contained in:
Marko Mäkelä 2025-07-17 12:24:25 +03:00
commit cedfe8eca4
4 changed files with 45 additions and 1 deletions

View file

@ -1760,6 +1760,11 @@ ATTRIBUTE_COLD buf_pool_t::shrink_status buf_pool_t::shrink(size_t size)
buf_flush_relocate_on_flush_list(b, &block->page);
mysql_mutex_unlock(&flush_list_mutex);
}
else
{
ut_d(if (auto om= b->oldest_modification()) ut_ad(om == 2));
b->oldest_modification_.store(0, std::memory_order_relaxed);
}
}
/* relocate LRU list */
@ -2091,10 +2096,11 @@ ATTRIBUTE_COLD void buf_pool_t::resize(size_t size, THD *thd) noexcept
while (buf_page_t *b= UT_LIST_GET_FIRST(withdrawn))
{
ut_ad(!b->oldest_modification());
ut_ad(b->state() == buf_page_t::NOT_USED);
UT_LIST_REMOVE(withdrawn, b);
UT_LIST_ADD_LAST(free, b);
ut_d(b->in_free_list= true);
ut_ad(b->state() == buf_page_t::NOT_USED);
b->lock.init();
}