diff --git a/storage/innobase/include/log0recv.h b/storage/innobase/include/log0recv.h index 80d1708fae1..39e705654e1 100644 --- a/storage/innobase/include/log0recv.h +++ b/storage/innobase/include/log0recv.h @@ -630,7 +630,7 @@ struct recv_sys_t { Spaces *spaces; /** Number of not processed hashed file addresses in the hash table */ - ulint n_addrs; + std::atomic n_addrs; /** Doublewrite buffer pages, destroyed after recovery completes */ dblwr::recv::DBLWR *dblwr; diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 79f0aa4b17d..719a0a9cf28 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -1246,7 +1246,7 @@ void recv_apply_hashed_log_recs(log_t &log, bool allow_ibuf) { recv_sys->apply_log_recs = true; recv_sys->apply_batch_on = true; - auto batch_size = recv_sys->n_addrs; + auto batch_size = recv_sys->n_addrs.load(std::memory_order_acquire); ib::info(ER_IB_MSG_707, ulonglong{batch_size}); @@ -1309,15 +1309,11 @@ void recv_apply_hashed_log_recs(log_t &log, bool allow_ibuf) { } /* Wait until all the pages have been processed */ - - while (recv_sys->n_addrs != 0) { - mutex_exit(&recv_sys->mutex); - + mutex_exit(&recv_sys->mutex); + while (recv_sys->n_addrs.load() != 0) { std::this_thread::sleep_for(std::chrono::milliseconds(500)); - - mutex_enter(&recv_sys->mutex); } - + mutex_enter(&recv_sys->mutex); if (!allow_ibuf) { /* Flush all the file pages to disk and invalidate them in the buffer pool */