From adf1715d9523e98a29923a620df8b854b50ae54e Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Wed, 21 Aug 2019 15:04:47 +0100 Subject: [PATCH] journal: fix race between player shut down and cache rebalance 25a23364 was supposed to fix this race, but it was not enough: there was still a window between `prefetch` is queued for execution in handle_cache_rebalanced and is actually executed, during which shut_down can be called and completed. Signed-off-by: Mykola Golub --- src/journal/JournalPlayer.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/journal/JournalPlayer.cc b/src/journal/JournalPlayer.cc index 02df4dfb7e98..9033c93f2fb7 100644 --- a/src/journal/JournalPlayer.cc +++ b/src/journal/JournalPlayer.cc @@ -120,6 +120,10 @@ void JournalPlayer::prefetch() { std::lock_guard locker{m_lock}; ceph_assert(m_state == STATE_INIT); + if (m_shut_down) { + return; + } + if (m_cache_manager_handler != nullptr && m_max_fetch_bytes == 0) { m_state = STATE_WAITCACHE; return; @@ -851,9 +855,11 @@ void JournalPlayer::handle_cache_rebalanced(uint64_t new_cache_bytes) { if (m_state == STATE_WAITCACHE) { m_state = STATE_INIT; if (m_max_fetch_bytes >= min_bytes) { + m_async_op_tracker.start_op(); auto ctx = new FunctionContext( [this](int r) { prefetch(); + m_async_op_tracker.finish_op(); }); m_journal_metadata->queue(ctx, 0); return; -- 2.47.3