summaryrefslogtreecommitdiff
path: root/file/file_prefetch_buffer.cc
diff options
context:
space:
mode:
authorAkanksha Mahajan <akankshamahajan@fb.com>2022-04-06 18:36:23 -0700
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>2022-04-06 18:36:23 -0700
commit7ea26abb8b8625ccd4916f95fbd9466c8947f5bd (patch)
tree9a9954442b70c289c9f51e71b70adeb75d15e852 /file/file_prefetch_buffer.cc
parente03f8a0c12b93250e4c5c508f90aaf87d9494833 (diff)
Fix reseting of async_read_in_progress_ variable in FilePrefetchBuffer to call Poll API (#9815)
Summary: Currently RocksDB reset async_read_in_progress_ in callback due to which underlying filesystem relying on Poll API won't be called leading to stale memory access. In order to fix it, async_read_in_progress_ will be reset after Poll API is called to make sure underlying file_system waiting on Poll can clear its state or take appropriate action. Pull Request resolved: https://github.com/facebook/rocksdb/pull/9815 Test Plan: CircleCI tests Reviewed By: anand1976 Differential Revision: D35451534 Pulled By: akankshamahajan15 fbshipit-source-id: b70ef6251a7aa9ed4876ba5e5100baa33d7d474c
Diffstat (limited to 'file/file_prefetch_buffer.cc')
-rw-r--r--file/file_prefetch_buffer.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/file/file_prefetch_buffer.cc b/file/file_prefetch_buffer.cc
index ef349c2b8..1fce53b65 100644
--- a/file/file_prefetch_buffer.cc
+++ b/file/file_prefetch_buffer.cc
@@ -231,7 +231,10 @@ Status FilePrefetchBuffer::PrefetchAsync(const IOOptions& opts,
handles.emplace_back(io_handle_);
fs_->Poll(handles, 1).PermitUncheckedError();
}
- // Release io_handle_ after the Poll API as request has been completed.
+
+ // Reset and Release io_handle_ after the Poll API as request has been
+ // completed.
+ async_read_in_progress_ = false;
if (io_handle_ != nullptr && del_fn_ != nullptr) {
del_fn_(io_handle_);
io_handle_ = nullptr;
@@ -512,7 +515,6 @@ bool FilePrefetchBuffer::TryReadFromCacheAsync(
void FilePrefetchBuffer::PrefetchAsyncCallback(const FSReadRequest& req,
void* /*cb_arg*/) {
- async_read_in_progress_ = false;
uint32_t index = curr_ ^ 1;
if (req.status.ok()) {
if (req.offset + req.result.size() <=