Add experimental new FS API AbortIO to cancel read request (#9901)

Summary:
Add experimental new API AbortIO in FileSystem to abort the
read requests submitted asynchronously through ReadAsync API.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/9901

Test Plan: Existing tests

Reviewed By: anand1976

Differential Revision: D35885591

Pulled By: akankshamahajan15

fbshipit-source-id: df3944e6e9e6e487af1fa688376b4abb6837fb02
This commit is contained in:
Akanksha Mahajan 2022-04-25 14:20:03 -07:00 committed by Facebook GitHub Bot
parent ac29645743
commit 5bd374b392
4 changed files with 28 additions and 1 deletions

View File

@ -5,6 +5,10 @@
### Public API changes
* Add rollback_deletion_type_callback to TransactionDBOptions so that write-prepared transactions know whether to issue a Delete or SingleDelete to cancel a previous key written during prior prepare phase. The PR aims to prevent mixing SingleDeletes and Deletes for the same key that can lead to undefined behaviors for write-prepared transactions.
* EXPERIMENTAL: Add new API AbortIO in file_system to abort the read requests submitted asynchronously.
### Bug Fixes
* RocksDB calls FileSystem::Poll API during FilePrefetchBuffer destruction which impacts performance as it waits for read requets completion which is not needed anymore. Calling FileSystem::AbortIO to abort those requests instead fixes that performance issue.
## 7.2.0 (04/15/2022)
### Bug Fixes

7
env/fs_posix.cc vendored
View File

@ -1118,6 +1118,13 @@ class PosixFileSystem : public FileSystem {
#endif
}
// TODO akanksha: Look into flags and see how to provide support for AbortIO
// in posix for IOUring requests. Currently it calls Poll to wait for requests
// to complete the request.
virtual IOStatus AbortIO(std::vector<void*>& io_handles) override {
return Poll(io_handles, io_handles.size());
}
#if defined(ROCKSDB_IOURING_PRESENT)
// io_uring instance
std::unique_ptr<ThreadLocalPtr> thread_local_io_urings_;

View File

@ -92,7 +92,8 @@ class FilePrefetchBuffer {
if (async_read_in_progress_ && fs_ != nullptr) {
std::vector<void*> handles;
handles.emplace_back(io_handle_);
fs_->Poll(handles, 1).PermitUncheckedError();
Status s = fs_->AbortIO(handles);
assert(s.ok());
}
// Release io_handle_.
if (io_handle_ != nullptr && del_fn_ != nullptr) {

View File

@ -668,6 +668,17 @@ class FileSystem : public Customizable {
return IOStatus::OK();
}
// EXPERIMENTAL
// Abort the read IO requests submitted asynchronously. Underlying FS is
// required to support AbortIO API. AbortIO implementation should ensure that
// the all the read requests related to io_handles should be aborted and
// it shouldn't call the callback for these io_handles.
//
// Default implementation is to return IOStatus::OK.
virtual IOStatus AbortIO(std::vector<void*>& /*io_handles*/) {
return IOStatus::OK();
}
// If you're adding methods here, remember to add them to EnvWrapper too.
private:
@ -1500,6 +1511,10 @@ class FileSystemWrapper : public FileSystem {
return target_->Poll(io_handles, min_completions);
}
virtual IOStatus AbortIO(std::vector<void*>& io_handles) override {
return target_->AbortIO(io_handles);
}
protected:
std::shared_ptr<FileSystem> target_;
};