Skip to content

Commit

Permalink
fix(tiering): Fix pending leak during immediate stash error (dragonfl…
Browse files Browse the repository at this point in the history
  • Loading branch information
dranikpg authored Jun 26, 2024
1 parent f28bd93 commit 1dfb604
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/server/tiering/disk_storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
8 changes: 7 additions & 1 deletion src/server/tiering/op_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 1dfb604

Please sign in to comment.