Skip to content

[ISSUE #10193] Fix incorrect min offset when next store returns -1#10236

Closed
Wubabalala wants to merge 1 commit intoapache:developfrom
Wubabalala:fix/issue-10193-tiered-min-offset
Closed

[ISSUE #10193] Fix incorrect min offset when next store returns -1#10236
Wubabalala wants to merge 1 commit intoapache:developfrom
Wubabalala:fix/issue-10193-tiered-min-offset

Conversation

@Wubabalala
Copy link
Copy Markdown

Which Issue(s) This PR Fixes

Brief Description

TieredMessageStore.getMinOffsetInQueue() merges the min offset from the next store and tiered store using Math.min(). However, when the next store has no valid data, it returns -1 as a sentinel value. This -1 is not a real offset but still participates in the Math.min(-1, tieredOffset) comparison, which always returns -1 and silently discards a valid tiered store offset.

The fix adds a guard for minOffsetInNextStore < 0 before the Math.min call, mirroring the existing minOffsetInTieredStore < 0 guard above it. When the next store is invalid, the tiered store offset is returned directly.

How Did You Test This Change?

Added a test case in TieredMessageStoreTest.testGetMinOffsetInQueue(): set the next store to return -1 while the tiered store holds a valid offset, and verify the tiered offset is returned instead of -1. All 111 tieredstore module tests pass.

…s -1

When the local store has no valid min offset and returns -1 as a sentinel
value, TieredMessageStore.getMinOffsetInQueue() incorrectly returns -1
via Math.min(-1, tieredOffset), ignoring a valid tiered store offset.

Add a guard for minOffsetInNextStore < 0 before the Math.min comparison,
returning the tiered store offset directly when the local store has no
valid data. Add test case covering local=-1 with valid tiered offset.
@Wubabalala
Copy link
Copy Markdown
Author

Sorry, I didn't notice #10194 was already submitted — the PR wasn't linked on the issue when I checked. Our fixes are identical. Closing this in favor of #10194.

@Wubabalala Wubabalala closed this Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Incorrect min offset returned from TieredMessageStore when local store returns -1

1 participant