[fix][broker] Fix readCompacted skipping tombstones within compaction horizon#26190
Open
grishaf wants to merge 2 commits into
Open
[fix][broker] Fix readCompacted skipping tombstones within compaction horizon#26190grishaf wants to merge 2 commits into
grishaf wants to merge 2 commits into
Conversation
When the compacted ledger has no entry for the current cursor position but the reader is still within the compaction horizon, fall back to the original managed ledger instead of seeking to horizon + 1. Co-authored-by: Cursor <cursoragent@cursor.com>
Resolve CompactionTest.java conflict by keeping both testTableViewMissesDeletesWhenCompactionRunsBeforeTombstonesConsumed and upstream testReaderReadOnDeletedLedger. Co-authored-by: Cursor <cursoragent@cursor.com>
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
readCompacted=truereaders could miss delete tombstones when a second compaction ran before those tombstones were consumed.CompactedTopicUtilsjumped the cursor tohorizon + 1whenever the compacted ledger returned no entry, skipping unread messages in the original topic between the current position and the compaction horizon.The fix falls back to the original managed ledger at the current cursor instead of seeking past the horizon.
Issue
readCompacteduses a hybrid read path:When
findStartPointreturnsNEWER_THAN_COMPACTED(e.g. a tombstone exists in the original topic but not in the compacted ledger),readCompactedEntriesreturns empty. The broker then seeked tohorizon + 1, skipping tombstones still sitting in the original ledger between the reader cursor and the horizon.Race
readCompacted=trueand consumes the compacted snapshot.horizon + 1→ tombstones are never delivered.Impact on TableView
TableView builds its map from a continuous
readCompactedreader. If tombstones are skipped:onUpdate/onRemovecallbacks for those deletes never fireAny client using a long-lived
readCompactedreader or TableView (Java, Go, etc.) inherits this broker behavior; no client-side change is required once the broker stops skipping.Fix
In
CompactedTopicUtils, when the compacted read returns empty, read from the original managed ledger at the current cursor (readEntries/readEntriesWithSkipOrWait) instead of seeking tohorizon + 1.Made with Cursor