Fix table cache leak when InstallCompactionResults fails#14549
Closed
pdillinger wants to merge 2 commits intofacebook:mainfrom
Closed
Fix table cache leak when InstallCompactionResults fails#14549pdillinger wants to merge 2 commits intofacebook:mainfrom
pdillinger wants to merge 2 commits intofacebook:mainfrom
Conversation
Summary: When CompactionJob::Run() succeeds but Install() fails (e.g., LogAndApply MANIFEST I/O error), compact_->status was never updated with the install failure. CleanupCompaction() passed the stale OK status to SubcompactionState::Cleanup(), which skipped ReleaseObsolete -- leaking table cache entries for output files that were cached by VerifyOutputFiles but never installed into any Version. This is the same class of bug fixed in facebook#14469 (where Run() failed after VerifyOutputFiles), but in the Install() failure path. The FindObsoleteFiles full-scan backstop would normally catch this, but fails under crash test metadata read fault injection (--open_metadata_read_fault_one_in), causing the TEST_VerifyNoObsoleteFilesCached assertion to fire during Close(). Fix: propagate Install()'s local status back to compact_->status before CleanupCompaction(), so Cleanup() sees the failure and calls ReleaseObsolete on the output files. Test Plan: New unit test DBCompactionTest.LeakedTableCacheEntryOnInstallFailure: - Without fix (ASAN): assertion fires -- "File 12 is not live nor quarantined" - With fix (ASAN): passes -- ReleaseObsolete properly cleans up the entry ``` COMPILE_WITH_ASAN=1 make -j db_compaction_test ./db_compaction_test --gtest_filter="DBCompactionTest.LeakedTableCacheEntry*" [ PASSED ] 2 tests. ``` Tasks: T218515781
|
@pdillinger has imported this pull request. If you are a Meta employee, you can view this in D99155908. |
✅ clang-tidy: No findings on changed linesCompleted in 369.6s. |
joshkang97
reviewed
Apr 1, 2026
db/compaction/compaction_job.cc
Outdated
| // (local status = error), Cleanup would see overall_status = OK and skip | ||
| // ReleaseObsolete, leaking table cache entries for output files that were | ||
| // never installed into any Version. | ||
| compact_->status = status; |
Contributor
There was a problem hiding this comment.
2026-04-01T21:04:35.3201315Z 0x00007f77c200742f in __GI___wait4 (pid=3939747, stat_loc=0x7f77c18f01ec, options=0, usage=0x0) at ../sysdeps/unix/sysv/linux/wait4.c:30
2026-04-01T21:04:35.3202548Z 30 ../sysdeps/unix/sysv/linux/wait4.c: No such file or directory.
2026-04-01T21:04:35.3203939Z #4 0x00005595e5c1dec8 in alternative_rocksdb_ns::CompactionState::~CompactionState (this=0x7f77bc008060, __in_chrg=<optimized out>) at ./db/compaction/compaction_state.h:23
2026-04-01T21:04:35.3205165Z 23 class CompactionState {
2026-04-01T21:04:35.3206035Z #5 alternative_rocksdb_ns::CompactionJob::CleanupCompaction (this=this@entry=0x7f77c18f13f0) at db/compaction/compaction_job.cc:2567
Seems like status check is missing or needs to be ignored
|
@pdillinger has imported this pull request. If you are a Meta employee, you can view this in D99155908. |
joshkang97
approved these changes
Apr 2, 2026
|
@pdillinger merged this pull request in abc1f7c. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
When CompactionJob::Run() succeeds but Install() fails (e.g., LogAndApply MANIFEST I/O error), compact_->status was never updated with the install failure. CleanupCompaction() passed the stale OK status to SubcompactionState::Cleanup(), which skipped ReleaseObsolete -- leaking table cache entries for output files that were cached by VerifyOutputFiles but never installed into any Version.
This is the same class of bug fixed in #14469 (where Run() failed after VerifyOutputFiles), but in the Install() failure path. The FindObsoleteFiles full-scan backstop would normally catch this, but fails under crash test metadata read fault injection
(--open_metadata_read_fault_one_in), causing the
TEST_VerifyNoObsoleteFilesCached assertion to fire during Close().
Fix: propagate Install()'s local status back to compact_->status before CleanupCompaction(), so Cleanup() sees the failure and calls ReleaseObsolete on the output files.
Test Plan:
New unit test DBCompactionTest.LeakedTableCacheEntryOnInstallFailure:
Tasks: T218515781