Fix Kinesis offset handling for inclusive start sequence numbers and empty batches#18231
Open
utafrali wants to merge 1 commit intoapache:masterfrom
Open
Conversation
xiangfu0
reviewed
Apr 16, 2026
Contributor
xiangfu0
left a comment
There was a problem hiding this comment.
Found one high-signal compatibility risk; see inline comment.
| return JsonUtils.newObjectNode().put(_shardId, _sequenceNumber).toString(); | ||
| ObjectNode node = JsonUtils.newObjectNode().put(_shardId, _sequenceNumber); | ||
| if (_inclusive) { | ||
| node.put("inclusive", true); |
Contributor
There was a problem hiding this comment.
Adding inclusive to the serialized offset changes the persisted wire format from {"<shard>":"<seq>"} to a two-field JSON object. Older Pinot binaries only accept the one-field form in new KinesisPartitionGroupOffset(String), so a rolling upgrade or rollback can fail as soon as a new controller/server writes one of these offsets into shared metadata. Because stream offsets cross process and version boundaries, this needs a backward-compatible encoding strategy or a rollout plan that keeps the on-disk format stable.
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.
Fixes #18220
Addressed the two issues from the TODOs. The start sequence number for a new partition is inclusive, but the code was using AFTER_SEQUENCE_NUMBER which lost the first message. Fixed by checking startOffset.isInclusive() and using AT_SEQUENCE_NUMBER when appropriate.
Also fixed empty batch handling. Kinesis can return empty results temporarily even when records are available. We now check if there's a non-null next shard iterator and continue using it on the next cycle instead of treating it as fully caught up.
Added tests for both fixes.