fix(tiering): Fix pending leak during immediate stash error (#3219)

This commit is contained in:
Vladislav 2024-06-26 10:01:26 +03:00 committed by GitHub
parent f28bd93854
commit 1dfb604d97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View file

@ -181,7 +181,7 @@ DiskStorage::Stats DiskStorage::GetStats() const {
std::error_code DiskStorage::Grow(off_t grow_size) {
off_t start = size_;
if (off_t(alloc_.capacity()) + grow_size >= max_size_)
if (off_t(alloc_.capacity()) + grow_size > max_size_)
return std::make_error_code(std::errc::no_space_on_device);
if (std::exchange(grow_pending_, true))

View file

@ -42,6 +42,8 @@ std::error_code OpManager::Open(std::string_view file) {
void OpManager::Close() {
storage_.Close();
DCHECK(pending_stash_ver_.empty());
DCHECK(pending_reads_.empty());
}
void OpManager::Enqueue(EntryId id, DiskSegment segment, ReadCallback cb) {
@ -79,7 +81,11 @@ std::error_code OpManager::Stash(EntryId id_ref, std::string_view value) {
auto io_cb = [this, version, id = std::move(id)](DiskSegment segment, std::error_code ec) {
ProcessStashed(Borrowed(id), version, segment, ec);
};
return storage_.Stash(buf_view, std::move(io_cb));
auto ec = storage_.Stash(buf_view, std::move(io_cb));
if (ec)
pending_stash_ver_.erase(ToOwned(id_ref));
return ec;
}
OpManager::ReadOp& OpManager::PrepareRead(DiskSegment aligned_segment) {