Commit 98287bd2 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-33009 Server hangs for a long time with innodb_undo_log_truncate=ON

trx_purge_truncate_history(): Release buf_pool.flush_list_mutex
and 'dummily' acquire and release buf_pool.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 5dbe7a8c (MDEV-32757).

Tested by: Axel Schwenke (on Ubuntu 18.04 and Ubuntu 20.04)
Reviewed by: Vladislav Lesin
parent aff5ed39
......@@ -687,8 +687,8 @@ TRANSACTIONAL_TARGET void trx_purge_truncate_history()
mini-transaction commit and the server was killed, then
discarding the to-be-trimmed pages without flushing would
break crash recovery. */
mysql_mutex_lock(&buf_pool.flush_list_mutex);
rescan:
mysql_mutex_lock(&buf_pool.flush_list_mutex);
for (buf_page_t *bpage= UT_LIST_GET_LAST(buf_pool.flush_list); bpage; )
{
ut_ad(bpage->oldest_modification());
......@@ -730,7 +730,17 @@ TRANSACTIONAL_TARGET void trx_purge_truncate_history()
mysql_mutex_lock(&buf_pool.flush_list_mutex);
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.mutex);
mysql_mutex_unlock(&buf_pool.mutex);
goto rescan;
}
}
bpage= prev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment