From 27297d124873015af4ccf801b17281ce910f77f5 Mon Sep 17 00:00:00 2001 From: Hui Xiao Date: Tue, 26 Sep 2023 18:44:41 -0700 Subject: [PATCH] Only fallback to RocksDB internal prefetching on unsupported FS prefetching (#11897) Summary: **Context/Summary:** https://github.com/facebook/rocksdb/pull/11631 introduced an undesired fallback behavior to RocksDB internal prefetching even when FS prefetching return non-OK status other than "Unsupported". We only want to fall back when FS prefetching is not supported. Pull Request resolved: https://github.com/facebook/rocksdb/pull/11897 Test Plan: CI Reviewed By: ajkr Differential Revision: D49667055 Pulled By: hx235 fbshipit-source-id: fa36e4e5d6dc9507080217035f9d6ff8e4abda28 --- table/block_based/block_prefetcher.cc | 7 +++---- unreleased_history/bug_fixes/fallback_only_unsupported.md | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 unreleased_history/bug_fixes/fallback_only_unsupported.md diff --git a/table/block_based/block_prefetcher.cc b/table/block_based/block_prefetcher.cc index 0af5abaf0..18b54c739 100644 --- a/table/block_based/block_prefetcher.cc +++ b/table/block_based/block_prefetcher.cc @@ -37,11 +37,12 @@ void BlockPrefetcher::PrefetchIfNeeded(const BlockBasedTable::Rep* rep, if (s.ok()) { readahead_limit_ = offset + len + compaction_readahead_size_; return; + } else if (!s.IsNotSupported()) { + return; } } // If FS prefetch is not supported, fall back to use internal prefetch - // buffer. Discarding other return status of Prefetch calls intentionally, - // as we can fallback to reading from disk if Prefetch fails. + // buffer. // // num_file_reads is used by FilePrefetchBuffer only when // implicit_auto_readahead is set. @@ -123,8 +124,6 @@ void BlockPrefetcher::PrefetchIfNeeded(const BlockBasedTable::Rep* rep, } // If prefetch is not supported, fall back to use internal prefetch buffer. - // Discarding other return status of Prefetch calls intentionally, as - // we can fallback to reading from disk if Prefetch fails. IOOptions opts; Status s = rep->file->PrepareIOOptions(read_options, opts); if (!s.ok()) { diff --git a/unreleased_history/bug_fixes/fallback_only_unsupported.md b/unreleased_history/bug_fixes/fallback_only_unsupported.md new file mode 100644 index 000000000..feb02ce3b --- /dev/null +++ b/unreleased_history/bug_fixes/fallback_only_unsupported.md @@ -0,0 +1 @@ +Fixed a bug where compaction read under non direct IO still falls back to RocksDB internal prefetching after file system's prefetching returns non-OK status other than `Status::NotSupported()`