[fix][broker] Fix getEstimatedSizeSinceMarkDeletePosition throw IllegalArgumentException#26184
Open
Technoboy- wants to merge 3 commits into
Open
[fix][broker] Fix getEstimatedSizeSinceMarkDeletePosition throw IllegalArgumentException#26184Technoboy- wants to merge 3 commits into
getEstimatedSizeSinceMarkDeletePosition throw IllegalArgumentException#26184Technoboy- wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a production warning where ManagedCursorImpl#getEstimatedSizeSinceMarkDeletePosition() could throw IllegalArgumentException when the cursor’s markDeletePosition is ahead of the ledger’s lastPosition (creating an invalid Guava Range), which caused compaction checks to be skipped.
Changes:
- Add an early-return guard in
getEstimatedSizeSinceMarkDeletePosition()whenmarkDeletePositionisnullor>= lastPosition, preventing invalidRangeconstruction. - Reuse a single
lastPositionsnapshot when computing the backlog range for both deleted-message counting and entry counting. - Add a unit test covering the “cursor markDeletePosition ahead of lastPosition” scenario.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java | Prevent invalid (markDelete..last] ranges by returning 0 when mark-delete is at/after last position; use a consistent lastPosition snapshot for range calculations. |
| managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java | Adds regression test ensuring estimated unacked size returns 0 (and doesn’t throw) when the cursor is ahead of the ledger last position. |
getEstimatedSizeSinceMarkDeletePosition throw IllegalArgumentExceptiongetEstimatedSizeSinceMarkDeletePosition throw IllegalArgumentException
poorbarcode
approved these changes
Jul 13, 2026
poorbarcode
approved these changes
Jul 14, 2026
nodece
approved these changes
Jul 14, 2026
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
Modifications
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