Repository navigation
[fix][broker] Preserve compaction state on ledger close failure - #26665
Merged
nodece merged 2 commits intoSep 22, 2026
Merged
Conversation
nodece
reviewed
Sep 21, 2026
nodece
left a comment
Member
There was a problem hiding this comment.
Verified the ordering fix — this checks out from my side:
- The bug is real: with ack-before-close, a close failure routes into the
whenCompletecleanup which deletes a ledger the compaction subscription already references.CompactedTopicImpl's no-such-ledger fallback (lines 79-97) is evidence this failure shape is expected in practice. - The new order matches
AbstractTwoPhaseCompactor(close at line 212, ack at line 213 there); the deviation dates back to #18195, where the phase-two chain was copied with the two steps inverted. - Failure-path enumeration: close failure -> unpublished ledger, delete is safe; ack failure -> closed-but-unpublished, delete is safe; flush failure path unchanged.
- I ran
CompactionConcurrencyTestlocally on this branch: 2/2 pass, including the new regression test. The metadata-conflict injection through the real ledger manager is a nicely realistic way to trigger an actual BookKeeper close failure.
Two known trade-offs that predate this change (also present in AbstractTwoPhaseCompactor, so not blockers — just noting): a broker crash between close and ack leaves an orphaned closed ledger with no GC, and an ack that persists on the broker but fails the caller can still trigger deleting a published ledger. Both windows existed before; this change strictly narrows them.
Non-code nit: the PR description still has template residue (unchecked verification options, example bullets).
Review assisted by Claude Code (AI-assisted review), posted by @nodece.
Contributor
Author
|
@nodece Okay, it has already been processed. |
nodece
approved these changes
Sep 22, 2026
lhotari
pushed a commit
that referenced
this pull request
Sep 23, 2026
(cherry picked from commit b642e8e)
lhotari
pushed a commit
that referenced
this pull request
Sep 23, 2026
(cherry picked from commit b642e8e)
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.
Motivation
StrategicTwoPhaseCompactoracknowledges the compaction subscription with the new ledger ID before closing that ledger. If closing fails after the broker has processed the acknowledgment, the failure cleanup deletes a ledger that the subscription already references.This follows up on #26576 by fixing the publication order.
Modifications
AbstractTwoPhaseCompactor.CompactionConcurrencyTest. It uses a real broker and BookKeeper, persists conflicting ledger metadata to trigger a real close failure, and verifies preservation of the previous compaction state, cleanup of the failed ledger, and successful retry.Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes