diff --git a/HISTORY.md b/HISTORY.md index 725e2c129..7d622caa9 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,6 +3,7 @@ ### Bug Fixes * Fixed a bug where manual flush would block forever even though flush options had wait=false. * Fixed a bug where RocksDB could corrupt DBs with `avoid_flush_during_recovery == true` by removing valid WALs, leading to `Status::Corruption` with message like "SST file is ahead of WALs" when attempting to reopen. +* Fixed a bug in async_io path where incorrect length of data is read by FilePrefetchBuffer if data is consumed from two populated buffers and request for more data is sent. ### New Features * DB::GetLiveFilesStorageInfo is ready for production use. diff --git a/env/fs_posix.cc b/env/fs_posix.cc index 629ebe5b8..057058d24 100644 --- a/env/fs_posix.cc +++ b/env/fs_posix.cc @@ -1122,7 +1122,13 @@ class PosixFileSystem : public FileSystem { // in posix for IOUring requests. Currently it calls Poll to wait for requests // to complete the request. virtual IOStatus AbortIO(std::vector& io_handles) override { - return Poll(io_handles, io_handles.size()); + IOStatus s = Poll(io_handles, io_handles.size()); + // If Poll is not supported then it didn't submit any request and it should + // return OK. + if (s.IsNotSupported()) { + return IOStatus::OK(); + } + return s; } #if defined(ROCKSDB_IOURING_PRESENT) diff --git a/file/file_prefetch_buffer.cc b/file/file_prefetch_buffer.cc index ec92758fe..222166876 100644 --- a/file/file_prefetch_buffer.cc +++ b/file/file_prefetch_buffer.cc @@ -282,7 +282,7 @@ Status FilePrefetchBuffer::PrefetchAsync(const IOOptions& opts, bufs_[curr_].offset_ + bufs_[curr_].buffer_.CurrentSize()) { offset += length; length = 0; - prefetch_size -= length; + prefetch_size = readahead_size; } // Data is overlapping i.e. some of the data is in curr_ buffer and remaining // in second buffer. @@ -311,7 +311,8 @@ Status FilePrefetchBuffer::PrefetchAsync(const IOOptions& opts, // sync prefetching and copy the remaining data to third buffer in the end. // swap the buffers. curr_ = curr_ ^ 1; - prefetch_size -= length; + // Update prefetch_size as length has been updated in CopyDataToBuffer. + prefetch_size = length + readahead_size; } // Update second again if swap happened.