Skip to content

KAFKA-19244: Add support for kafka-streams-groups.sh options (offset-related APIs) [1/N] #19646

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

Open
wants to merge 8 commits into
base: trunk
Choose a base branch
from

Conversation

aliehsaeedii
Copy link
Contributor

@aliehsaeedii aliehsaeedii commented May 5, 2025

This PR implements all the options for --reset-offset, (supports
--execute, --dry-run, --export). Includes unit and integration
tests.

  • --reset-offsets --topics <String: topics> --shift-by Long
  • --reset-offsets --topics <String: topics> --to-offset Long
  • --reset-offsets --topics <String: topics> -to-latest
  • --reset-offsets --topics <String: topics> -to-earliest
  • --reset-offsets --all-topics --shift-by Long
  • --reset-offsets --all-topics --to-offset Long
  • --reset-offsets --all-topics -to-latest
  • --reset-offsets --all-topics -to-earliest
  • --reset-offsets --all-topics -to-earliest
  • --reset-offsets --from-file String:fileName
  • --reset-offsets --topics <String: topics> --by-duration String:
    duration
  • --reset-offsets --all-topics --by-duration String: duration
  • --reset-offsets --topics <String: topics> --to-datetime String:
    datetime
  • --reset-offsets --all-topics --to-datetime String: datetime
  • --reset-offsets --topics <String: topics> -to-current
  • --reset-offsets --all-topics -to-current

@github-actions github-actions bot added triage PRs from the community tools clients labels May 5, 2025
@mjsax mjsax added streams KIP-1071 PRs related to KIP-1071 ci-approved and removed triage PRs from the community labels May 5, 2025
Copy link
Member

@bbejeck bbejeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @aliehsaeedii I made a pass over the non-testing code, I'll do more in a follow up review

throw new IllegalArgumentException("Cannot shift offset for partition " + topicPartition + " since there is no current committed offset");
}

return currentOffset.offset() + shiftBy;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to do any validation on what the acceptable values for shiftBy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume any long value should be accepted. Good point. I'll add some tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems shiftby 150 and -150 are already existing.

@aliehsaeedii aliehsaeedii changed the title KAFKA-19244: Add support for kafka-streams-groups.sh options (delete group, offset-related APIs) [1/2] KAFKA-19244: Add support for kafka-streams-groups.sh options (delete group, offset-related APIs) [1/N] May 19, 2025
@lucasbru lucasbru changed the title KAFKA-19244: Add support for kafka-streams-groups.sh options (delete group, offset-related APIs) [1/N] KAFKA-19244: Add support for kafka-streams-groups.sh options (offset-related APIs) [1/N] May 27, 2025
Copy link
Member

@lucasbru lucasbru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @aliehsaeedii ! Thanks for the PR. Mostly looking good to me, left a few comments


private Collection<TopicPartition> getPartitionsToReset(String groupId) throws ExecutionException, InterruptedException {
if (opts.options.has(opts.allTopicsOpt)) {
return getCommittedOffsets(groupId).keySet();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may not be the correct behavior. We only want to reset the offset of source topics, never the offset of repartition topics (which are also committed). For a clean reset, as implemented by the streams resetter, I think we want to delete the internal topics (through the other options). Resetting repartition topics to the beginning seems incorrect, since it will mean that we will reconsume these records in the downstream subtopologies.

@bbejeck Wdyt?

We are already describing the streams group, so I think this shouldn't be too hard to implement - we have to pass the source topics into this function.

return null;
}

Optional<Map<String, Map<TopicPartition, OffsetAndMetadata>>> resetPlanFromFile() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume quite a bit of this code was copied from the consumer group tool. Is there any chance of sharing some code? May not be the case, but since most of this code is just dealing with topic partitions and not with tasks, I wonder if there is an easy way to refactor functions like this into a common utility.

}
} catch (IOException e) {
e.printStackTrace();
// Ignore.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we want to fail here somehow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants