Fix wraparound in SstFileManager (#13010)

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

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 #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.

Reviewed By: anand1976

Differential Revision: D62535775

fbshipit-source-id: a7c44d6e0a4b5ff74bc47abfe57c32ca6770243d
This commit is contained in:
Nick Brekhus 2024-09-13 14:39:48 -07:00 committed by Facebook GitHub Bot
parent cabd2d8718
commit 40adb2bab7
1 changed files with 1 additions and 1 deletions

View File

@ -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;
}
@ -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;
}