Skip to content

Conversation

@sushantmane
Copy link
Contributor

Switch back to PubSubPosition based reads with offset as fallback

Code changes

  • Added new code behind a config. If so list the config names and their default values in the PR description.
  • Introduced new log lines.
    • Confirmed if logs need to be rate limited to avoid excessive logging.

Concurrency-Specific Checks

Both reviewer and PR author to verify

  • Code has no race conditions or thread safety issues.
  • Proper synchronization mechanisms (e.g., synchronized, RWLock) are used where needed.
  • No blocking calls inside critical sections that could lead to deadlocks or performance degradation.
  • Verified thread-safe collections are used (e.g., ConcurrentHashMap, CopyOnWriteArrayList).
  • Validated proper exception handling in multi-threaded code to avoid silent thread termination.

How was this PR tested?

  • New unit tests added.
  • New integration tests added.
  • Modified or extended existing tests.
  • Verified backward compatibility (if applicable).

Does this PR introduce any user-facing or breaking changes?

  • No. You can skip the rest of this section.
  • Yes. Clearly explain the behavior change and its impact.

Copilot AI review requested due to automatic review settings October 28, 2025 20:08
Copy link

Copilot AI left a 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.getPubSubPositionString utility method and its test
  • Replaces numeric offset comparisons with proper position comparisons using diffPosition and object equality
  • Updates deserializePositionWithOffsetFallback to remove the offset > 0 guard 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),
Copy link

Copilot AI Oct 28, 2025

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)

Suggested change
leaderMetadata == null ? "-" : pubSubPositionDeserializer.toPosition(leaderMetadata.upstreamPubSubPosition),
(leaderMetadata == null || leaderMetadata.upstreamPubSubPosition == null) ? "-" : pubSubPositionDeserializer.toPosition(leaderMetadata.upstreamPubSubPosition),

Copilot uses AI. Check for mistakes.
leaderMetadata == null
? "-"
: getPubSubPositionString(pubSubPositionDeserializer, leaderMetadata.upstreamPubSubPosition),
leaderMetadata == null ? "-" : pubSubPositionDeserializer.toPosition(leaderMetadata.upstreamPubSubPosition),
Copy link

Copilot AI Oct 28, 2025

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)

Suggested change
leaderMetadata == null ? "-" : pubSubPositionDeserializer.toPosition(leaderMetadata.upstreamPubSubPosition),
leaderMetadata == null || leaderMetadata.upstreamPubSubPosition == null ? "-" : pubSubPositionDeserializer.toPosition(leaderMetadata.upstreamPubSubPosition),

Copilot uses AI. Check for mistakes.
Comment on lines +903 to +904
pubSubPositionDeserializer
.toPosition(consumerRecord.getValue().leaderMetadataFooter.upstreamPubSubPosition))
Copy link

Copilot AI Oct 28, 2025

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)

Suggested change
pubSubPositionDeserializer
.toPosition(consumerRecord.getValue().leaderMetadataFooter.upstreamPubSubPosition))
consumerRecord.getValue().leaderMetadataFooter.upstreamPubSubPosition == null
? "-"
: pubSubPositionDeserializer.toPosition(consumerRecord.getValue().leaderMetadataFooter.upstreamPubSubPosition))

Copilot uses AI. Check for mistakes.

// Guard against regressions: honor the caller-provided minimum offset.
if (offset > 0 && position.getNumericOffset() < offset) {
if (position.getNumericOffset() < offset) {
Copy link

Copilot AI Oct 28, 2025

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.

Copilot uses AI. Check for mistakes.
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) {
Copy link

Copilot AI Oct 28, 2025

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.

Suggested change
if (position.getNumericOffset() < offset) {
if (offset > 0 && position.getNumericOffset() < offset) {

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

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.

@github-actions github-actions bot added the stale label Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant