Repository navigation
Report OnSubcompactionCompleted when a resumed subcompaction fails to restore its progress - #15530
Open
omkarhgawde wants to merge 1 commit into
Open
omkarhgawde wants to merge 1 commit into
omkarhgawde wants to merge 1 commit into
Conversation
… restore its progress Summary: `CompactionJob::ProcessKeyValueCompaction()` calls `NotifyOnSubcompactionBegin()` before `MaybeResumeSubcompactionProgressOnInputIterator()`. When the resume failed, the function set `sub_compact->status` and returned without a call to `NotifyOnSubcompactionCompleted()`. The resume fails when a saved output file cannot be read, when the key to resume from is outside the input, when the input iterator fails at that key, or when the saved blob progress cannot be restored. A listener then got `OnSubcompactionBegin()` with no matching `OnSubcompactionCompleted()`, so it could not close the event or see the failure status. Only `DB::OpenAndCompact()` with `OpenAndCompactOptions::allow_resumption` loads saved progress, so only the listeners of such a worker are affected. When there is no progress to resume, the function returns `NotFound`, and the subcompaction starts from the first key as before. The early return now calls `NotifyOnSubcompactionCompleted()`, and the event carries the resume error in `SubcompactionJobInfo::status`. `NotifyOnSubcompactionCompleted()` keeps its checks: it sends nothing when `NotifyOnSubcompactionBegin()` sent no event, or when the DB is shutting down. The resume error and what follows it do not change: the worker's compaction fails with that status, and the `CompactionService` implementation decides what the primary does. The diff also adds a release note under `unreleased_history/bug_fixes/`. Differential Revision: D128236290
|
@omkarhgawde has exported this pull request. If you are a Meta employee, you can view the originating Diff in D128236290. |
✅ clang-tidy: No findings on changed linesCompleted in 600.2s. |
✅ Claude Code ReviewAuto-triggered after CI passed — reviewing commit 3ae1d3f SummaryClean, well-scoped bug fix that correctly pairs High-severity findings (0): Full review (click to expand)Findings🔴 HIGHNone. 🟡 MEDIUMM1. Missing
|
| Context | Does code execute? | Assumptions hold? | Action needed? |
|---|---|---|---|
| Standard DB compaction | NO — MaybeResumeSubcompactionProgressOnInputIterator returns NotFound (no saved progress) |
N/A | None |
DB::OpenAndCompact with allow_resumption |
YES — this is the only context | YES | The fix targets this path |
| WritePreparedTxnDB | NO — OpenAndCompact is a worker path |
N/A | None |
| ReadOnly DB | NO | N/A | None |
| Shutdown race | SAFE — NotifyOnSubcompactionCompleted checks shutting_down_ (line 1549) |
YES | None |
| Canceled compaction | SAFE — NotifyOnSubcompactionCompleted checks notify_on_subcompaction_completion flag (line 1553) |
YES | None |
local_compaction_executor_ exception path |
CONSISTENT — also calls NotifyOnSubcompactionCompleted after error (line 2109) |
YES | None |
Positive Observations
- Correct use of
notify_on_subcompaction_completionguard: The fix leverages the existing idempotency flag inNotifyOnSubcompactionCompleted()(line 1553), which ensures the notification is only sent whenNotifyOnSubcompactionBegin()actually fired. This makes the fix safe even under edge cases (shutting down, no listeners, canceled compaction). sub_compact->statusis set before notification: Line 2158 setssub_compact->status = statusbefore the newNotifyOnSubcompactionCompletedcall, soBuildSubcompactionJobInfo()will correctly include the error status.- No resource leaks: At the early return point, all local resources (iterators, boundaries, read options) are in RAII containers that clean up automatically. No output files have been opened.
- Minimal, focused change: The 1-line production code fix is exactly right — no over-engineering.
- Good test coverage: The test creates a realistic scenario (delete saved output files, resume fails with Corruption) and validates the core invariant (begin_count == completed_count, corruption_count > 0).
- Release note is appropriate: Concise, identifies the specific API and conditions.
ℹ️ About this response
Generated by Claude Code.
Review methodology: claude_md/ci_review_prompt.md
Limitations:
- Claude may miss context from files not in the diff
- Large PRs may be truncated
- Always apply human judgment to AI suggestions
Commands:
/claude-review [context]— Request a code review/claude-query <question>— Ask about the PR or codebase
This branch has not been deployed
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:
CompactionJob::ProcessKeyValueCompaction()callsNotifyOnSubcompactionBegin()beforeMaybeResumeSubcompactionProgressOnInputIterator(). When the resume failed, the function setsub_compact->statusand returned without a call toNotifyOnSubcompactionCompleted(). The resume fails when a saved output file cannot be read, when the key to resume from is outside the input, when the input iterator fails at that key, or when the saved blob progress cannot be restored. A listener then gotOnSubcompactionBegin()with no matchingOnSubcompactionCompleted(), so it could not close the event or see the failure status.Only
DB::OpenAndCompact()withOpenAndCompactOptions::allow_resumptionloads saved progress, so only the listeners of such a worker are affected. When there is no progress to resume, the function returnsNotFound, and the subcompaction starts from the first key as before.The early return now calls
NotifyOnSubcompactionCompleted(), and the event carries the resume error inSubcompactionJobInfo::status.NotifyOnSubcompactionCompleted()keeps its checks: it sends nothing whenNotifyOnSubcompactionBegin()sent no event, or when the DB is shutting down. The resume error and what follows it do not change: the worker's compaction fails with that status, and theCompactionServiceimplementation decides what the primary does.The diff also adds a release note under
unreleased_history/bug_fixes/.Differential Revision: D128236290