Skip to content
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

SAMZA-2802: fetch empty topic metadata #1710

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Anilochka
Copy link

In the situation when a topic is empty, but not new (begin offset == end offset != 0) in fetchTopicPartitionsMetadata we subtract 1 from the end offset:
newestOffsets.put(KafkaUtil.toSystemStreamPartition(this.systemName, topicPartition), String.valueOf(offset - 1L));
and later in validateRestoreOffsets:

private static void validateRestoreOffsets(RestoreOffsets restoreOffsets, SystemAdmin systemAdmin) {
    String startingOffset = restoreOffsets.startingOffset;
    String endingOffset = restoreOffsets.endingOffset;
    // cannot enforce that starting offset be non null since SSPMetadata allows oldest offset == null for empty topics.
    if (endingOffset != null) {
      Preconditions.checkState(systemAdmin.offsetComparator(endingOffset, startingOffset) >= 0,
          String.format("Ending offset: %s must be equal to or greater than starting offset: %s",
              endingOffset, startingOffset));
    }
  }

we get endingOffset < startingOffset because of subtraction of 1 in fetchTopicPartitionsMetadata.

In this PR if-else block was added to don't subtract 1 from the ending offset when its equal to the beginning offset.

@Anilochka Anilochka changed the title BUG FIX fetch empty topic metadata SAMZA-2802 fetch empty topic metadata Nov 14, 2024
@Anilochka Anilochka changed the title SAMZA-2802 fetch empty topic metadata SAMZA-2802: fetch empty topic metadata Nov 22, 2024
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.

1 participant