diff --git a/storage/innobase/buf/buf0dump.cc b/storage/innobase/buf/buf0dump.cc index 2e6365eb39f..aaf07dd17eb 100644 --- a/storage/innobase/buf/buf0dump.cc +++ b/storage/innobase/buf/buf0dump.cc @@ -715,6 +715,10 @@ buf_load() ut_free(dump); + if (i == dump_n) { + os_aio_wait_until_no_pending_reads(); + } + ut_sprintf_timestamp(now); if (i == dump_n) { diff --git a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h index 9b5e5058f46..8f632305f7e 100644 --- a/storage/innobase/include/os0file.h +++ b/storage/innobase/include/os0file.h @@ -1116,6 +1116,10 @@ Only used on FLUSH TABLES...FOR EXPORT. */ void os_aio_wait_until_no_pending_writes(); +/** Wait until there are no pending asynchronous reads. */ +void os_aio_wait_until_no_pending_reads(); + + /** Prints info of the aio arrays. @param[in/out] file file where to print */ void diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 7a6829e7865..dde1975ea08 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -3828,6 +3828,20 @@ void os_aio_wait_until_no_pending_writes() buf_dblwr.wait_flush_buffered_writes(); } +/** Wait until there are no pending asynchronous reads. */ +void os_aio_wait_until_no_pending_reads() +{ + const auto notify_wait= read_slots->pending_io_count(); + + if (notify_wait) + tpool::tpool_wait_begin(); + + read_slots->wait(); + + if (notify_wait) + tpool::tpool_wait_end(); +} + /** Request a read or write. @param type I/O request @param buf buffer