Skip to content

Commit

Permalink
Fix wraparound in SstFileManager
Browse files Browse the repository at this point in the history
Summary: The OnAddFile cur_compactions_reserved_size_ accounting causes wraparound when re-opening a database with an unowned SstFileManager and during recovery. It was introduced in facebook#4164 which addresses out of space recovery with an unclear purpose. Compaction jobs do this accounting via EnoughRoomForCompaction/OnCompactionCompletion and to my understanding would never reuse a sst file name.

Differential Revision: D62535775
  • Loading branch information
Nick Brekhus authored and facebook-github-bot committed Sep 12, 2024
1 parent 43bc71f commit 11cb7a8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion file/sst_file_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ void SstFileManagerImpl::OnCompactionCompletion(Compaction* c) {
size_added_by_compaction += filemeta->fd.GetFileSize();
}
}
assert(cur_compactions_reserved_size_ >= size_added_by_compaction);
cur_compactions_reserved_size_ -= size_added_by_compaction;
}

Expand Down Expand Up @@ -450,7 +451,6 @@ void SstFileManagerImpl::OnAddFileImpl(const std::string& file_path,
// File was added before, we will just update the size
total_files_size_ -= tracked_file->second;
total_files_size_ += file_size;
cur_compactions_reserved_size_ -= file_size;
} else {
total_files_size_ += file_size;
}
Expand Down

0 comments on commit 11cb7a8

Please sign in to comment.