GeezerVison is showing github.com — [fix][broker] Preserve compaction state on ledger close failure by Denovo1998 · Pull Request #26665 · apache/pulsar
Conversation
Denovo1998
commented
Sep 20, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Motivation
StrategicTwoPhaseCompactor acknowledges 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
- Close the compacted ledger before acknowledging the compaction subscription, matching
AbstractTwoPhaseCompactor.
- If closing fails, skip the acknowledgment, attempt to delete the new ledger, and fail the compaction. The previously published ledger and cursor position remain unchanged.
- Add a regression test to the existing
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.
- Use AssertJ future assertions for bounded waits and failure diagnostics, and define the compaction strategy locally in the test.
Verifying this change
- Make sure that the change passes the CI checks.
(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:)
- Added integration tests for end-to-end deployment with large payloads (10MB)
- Extended integration test for recovery after broker failure
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
- Dependencies (add or upgrade a dependency)
- The public API
- The schema
- The default values of configurations
- The threading model
- The binary protocol
- The REST endpoints
- The admin CLI options
- The metrics
- Anything that affects deployment
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified the ordering fix — this checks out from my side:
- The bug is real: with ack-before-close, a close failure routes into the
whenComplete cleanup 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
CompactionConcurrencyTest locally 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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
@nodece Okay, it has already been processed.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
nodece
pushed a commit
to ascentstream/pulsar
that referenced
this pull request
Nov 16, 2026
Reviewers
nodece
nodece approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|