diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 94a8f1290c3d..66f05ee8dc69 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -366,6 +366,22 @@ static void buf_pool_register_chunk(buf_chunk_t *chunk) { buf_pool_chunk_map_t::value_type(chunk->blocks->frame, chunk)); } +ulint buf_get_flush_list_len(const buf_pool_t *buf_pool) { + ulint pages = 0; + if (buf_pool == nullptr) { + for (ulint i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t *buf_pool_instance; + + buf_pool_instance = buf_pool_from_array(i); + + pages += UT_LIST_GET_LEN(buf_pool_instance->flush_list); + } + } else { + pages = UT_LIST_GET_LEN(buf_pool->flush_list); + } + return (pages); +} + lsn_t buf_pool_get_oldest_modification_approx(void) { lsn_t lsn = 0; lsn_t oldest_lsn = 0; diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 4191455f08aa..c4ec6b71a363 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -3518,7 +3518,8 @@ static void buf_flush_page_coordinator_thread() { buf_flush_await_no_flushing(nullptr, BUF_FLUSH_LIST); buf_flush_await_no_flushing(nullptr, BUF_FLUSH_LRU); - } while (!success || n_flushed > 0 || are_any_read_ios_still_underway); + } while (!success || n_flushed > 0 || are_any_read_ios_still_underway || + buf_get_flush_list_len(nullptr) > 0); for (ulint i = 0; i < srv_buf_pool_instances; i++) { buf_pool_t *buf_pool = buf_pool_from_array(i); diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 8fc247a2db5b..29367aaa041e 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -1083,6 +1083,11 @@ has returned NULL and before invoking buf_pool_watch_unset(same_page_id). @return false if the given page was not read in, true if it was */ [[nodiscard]] bool buf_pool_watch_occurred(const page_id_t &page_id); +/** Get the current length of the flush list. +@param[in] buf_pool buffer pool instance or nullptr to all instances +@return number of pages in flush list */ +ulint buf_get_flush_list_len(const buf_pool_t *buf_pool); + /** Get total buffer pool statistics. @param[out] LRU_len Length of all lru lists @param[out] free_len Length of all free lists