diff --git a/util/file_reader_writer.cc b/util/file_reader_writer.cc index 3fc02bee3..86e1e9260 100644 --- a/util/file_reader_writer.cc +++ b/util/file_reader_writer.cc @@ -544,6 +544,11 @@ class ReadaheadRandomAccessFile : public RandomAccessFile { } virtual Status Prefetch(uint64_t offset, size_t n) override { + if (n < readahead_size_) { + // Don't allow smaller prefetches than the configured `readahead_size_`. + // `Read()` assumes a smaller prefetch buffer indicates EOF was reached. + return Status::OK(); + } size_t prefetch_offset = TruncateToPageBoundary(alignment_, offset); if (prefetch_offset == buffer_offset_) { return Status::OK();