From f98d2ef5b4ab633d74fb245a8b6520fe86514de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 15 Dec 2023 15:38:31 +0200 Subject: [PATCH] MDEV-33009 Server hangs for a long time with innodb_undo_log_truncate=ON trx_purge_truncate_history(): Release buf_pool.flush_list_mutex before starting a rescan of buf_pool.flush_list, to ensure that the buf_flush_page_cleaner thread (which may be holding buf_pool.mutex) will be able to proceed. This fixes up commit a0f02f743848fb6ef6d2a51960f77e1e38da1682 (MDEV-32757). Tested by: Axel Schwenke Reviewed by: Vladislav Lesin --- storage/innobase/trx/trx0purge.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index b06e3cb3e1b..702e76fc284 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -681,6 +681,13 @@ void trx_purge_truncate_history() if (prev != buf_pool.flush_hp.get()) { + /* The functions buf_pool_t::release_freed_page() or + buf_do_flush_list_batch() may be right now holding + buf_pool.mutex and waiting to acquire + buf_pool.flush_list_mutex. Ensure that they can proceed, + to avoid extreme waits. */ + mysql_mutex_unlock(&buf_pool.flush_list_mutex); + mysql_mutex_lock(&buf_pool.flush_list_mutex); /* Rescan, because we may have lost the position. */ bpage= UT_LIST_GET_LAST(buf_pool.flush_list); continue;