Skip to content

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