-
Notifications
You must be signed in to change notification settings - Fork 108
[server] Switch back to PubSubPosition based reads with offset as fallback #2242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[server] Switch back to PubSubPosition based reads with offset as fallback #2242
Conversation
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.
Pull Request Overview
This PR removes the getPubSubPositionString method and its associated test, replacing its usage with direct calls to pubSubPositionDeserializer.toPosition(). The key changes enable better position comparison by using actual PubSubPosition objects rather than numeric offsets, and utilize the deserializePositionWithOffsetFallback method for safer deserialization with fallback logic.
- Removes
PubSubUtil.getPubSubPositionStringutility method and its test - Replaces numeric offset comparisons with proper position comparisons using
diffPositionand object equality - Updates
deserializePositionWithOffsetFallbackto remove theoffset > 0guard condition - Integrates proper position deserialization with fallback in
extractUpstreamPosition
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| PubSubUtil.java | Removes getPubSubPositionString utility method |
| PubSubUtilTest.java | Removes test coverage for getPubSubPositionString |
| OffsetRecord.java | Removes unused import and updates deserializePositionWithOffsetFallback condition |
| KafkaTopicDumper.java | Replaces getPubSubPositionString with direct toPosition calls |
| StoreIngestionTask.java | Updates position deserialization condition and integrates fallback in extractUpstreamPosition |
| StoreIngestionTaskTest.java | Changes test assertions to use full position equality instead of numeric offset comparison |
| PartitionTracker.java | Replaces getPubSubPositionString with direct toPosition call |
| LeaderFollowerStoreIngestionTask.java | Replaces numeric offset comparisons with proper position comparisons using diffPosition and symbolic position checks |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| leaderMetadata == null | ||
| ? "-" | ||
| : getPubSubPositionString(pubSubPositionDeserializer, leaderMetadata.upstreamPubSubPosition), | ||
| leaderMetadata == null ? "-" : pubSubPositionDeserializer.toPosition(leaderMetadata.upstreamPubSubPosition), |
Copilot
AI
Oct 28, 2025
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.
Potential NullPointerException when leaderMetadata.upstreamPubSubPosition is null. The toPosition method throws an IllegalArgumentException when passed a null ByteBuffer. Add a null check for upstreamPubSubPosition or use a nested ternary to handle this case: leaderMetadata == null || leaderMetadata.upstreamPubSubPosition == null ? \"-\" : pubSubPositionDeserializer.toPosition(leaderMetadata.upstreamPubSubPosition)
| leaderMetadata == null ? "-" : pubSubPositionDeserializer.toPosition(leaderMetadata.upstreamPubSubPosition), | |
| (leaderMetadata == null || leaderMetadata.upstreamPubSubPosition == null) ? "-" : pubSubPositionDeserializer.toPosition(leaderMetadata.upstreamPubSubPosition), |
| leaderMetadata == null | ||
| ? "-" | ||
| : getPubSubPositionString(pubSubPositionDeserializer, leaderMetadata.upstreamPubSubPosition), | ||
| leaderMetadata == null ? "-" : pubSubPositionDeserializer.toPosition(leaderMetadata.upstreamPubSubPosition), |
Copilot
AI
Oct 28, 2025
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.
Potential NullPointerException when leaderMetadata.upstreamPubSubPosition is null. The toPosition method throws an IllegalArgumentException when passed a null ByteBuffer. Add a null check for upstreamPubSubPosition or use a nested ternary to handle this case: leaderMetadata == null || leaderMetadata.upstreamPubSubPosition == null ? \"-\" : pubSubPositionDeserializer.toPosition(leaderMetadata.upstreamPubSubPosition)
| leaderMetadata == null ? "-" : pubSubPositionDeserializer.toPosition(leaderMetadata.upstreamPubSubPosition), | |
| leaderMetadata == null || leaderMetadata.upstreamPubSubPosition == null ? "-" : pubSubPositionDeserializer.toPosition(leaderMetadata.upstreamPubSubPosition), |
| pubSubPositionDeserializer | ||
| .toPosition(consumerRecord.getValue().leaderMetadataFooter.upstreamPubSubPosition)) |
Copilot
AI
Oct 28, 2025
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.
Potential NullPointerException when upstreamPubSubPosition is null. The toPosition method throws an IllegalArgumentException when passed a null ByteBuffer. Consider adding a null check or using a defensive fallback similar to other parts of the codebase: upstreamPubSubPosition == null ? \"-\" : pubSubPositionDeserializer.toPosition(upstreamPubSubPosition)
| pubSubPositionDeserializer | |
| .toPosition(consumerRecord.getValue().leaderMetadataFooter.upstreamPubSubPosition)) | |
| consumerRecord.getValue().leaderMetadataFooter.upstreamPubSubPosition == null | |
| ? "-" | |
| : pubSubPositionDeserializer.toPosition(consumerRecord.getValue().leaderMetadataFooter.upstreamPubSubPosition)) |
|
|
||
| // Guard against regressions: honor the caller-provided minimum offset. | ||
| if (offset > 0 && position.getNumericOffset() < offset) { | ||
| if (position.getNumericOffset() < offset) { |
Copilot
AI
Oct 28, 2025
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.
Removing the offset > 0 check means that this condition will now fire even when offset is 0 or negative. This could be intentional for handling edge cases, but it changes the behavior for positions at offset 0. Consider documenting why the guard was removed or verifying that positions at offset 0 should be subject to this fallback logic.
| final PubSubPosition position = pubSubPositionDeserializer.toPosition(wireFormatBytes); | ||
| // Guard against regressions: honor the caller-provided minimum offset. | ||
| if (offset > 0 && position.getNumericOffset() < offset) { | ||
| if (position.getNumericOffset() < offset) { |
Copilot
AI
Oct 28, 2025
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.
Removing the offset > 0 check means that this condition will now fire even when offset is 0 or negative. This could be intentional for handling edge cases, but it changes the behavior for positions at offset 0. Consider documenting why the guard was removed or verifying that positions at offset 0 should be subject to this fallback logic.
| if (position.getNumericOffset() < offset) { | |
| if (offset > 0 && position.getNumericOffset() < offset) { |
|
Hi there. This pull request has been inactive for 30 days. To keep our review queue healthy, we plan to close it in 7 days unless there is new activity. If you are still working on this, please push a commit, leave a comment, or convert it to draft to signal intent. Thank you for your time and contributions. |
Switch back to PubSubPosition based reads with offset as fallback
Code changes
Concurrency-Specific Checks
Both reviewer and PR author to verify
synchronized,RWLock) are used where needed.ConcurrentHashMap,CopyOnWriteArrayList).How was this PR tested?
Does this PR introduce any user-facing or breaking changes?