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

Reset offsets increments sent offset by 1 #1167

Open
presjednik opened this issue May 31, 2023 · 0 comments
Open

Reset offsets increments sent offset by 1 #1167

presjednik opened this issue May 31, 2023 · 0 comments

Comments

@presjednik
Copy link

I couldn't find any documentation about this feature, so I hope someone can explain to me why the KafkaConsumerState class that handles the offset committing increments the sent offsets from TopicPartitionOffsetMetadata by one?

Here is the code:

      for (TopicPartitionOffsetMetadata t : offsetCommitRequest.getOffsets()) {
        if (t.getMetadata() == null) {
          offsetMap.put(
              new TopicPartition(t.getTopic(), t.getPartition()),
              new OffsetAndMetadata(t.getOffset() + 1));
        } else {
          offsetMap.put(
              new TopicPartition(t.getTopic(), t.getPartition()),
              new OffsetAndMetadata(t.getOffset() + 1, t.getMetadata()));
        }
      }

With this behaviour, if you want to commit the offset for a partition you need to send the wanted offset - 1. For example, if I want to set the offset to 0 i need to send this body:

{
	"offsets": [
		{
			"topic": "test-topic",
			"partition": 0,
			"offset": -1
		}
	]
}
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

No branches or pull requests

1 participant