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

group: reset all partitions if invoked with -partition -1 #48

Merged
merged 4 commits into from
Apr 17, 2017

Conversation

disq
Copy link
Contributor

@disq disq commented Apr 13, 2017

I'm new to Kafka (long time Kinesis user) so take this PR with a grain of salt :)
I thought that maybe you wouldn't want an implicit match-all-partitions logic in a potentially destructive (well, write) operation, so came up with the "-1" magic number. Maybe the -partition param can be a string, then it would accept all for all partitions etc.

group.go Outdated
if args.reset != "" && (args.topic == "" || args.partition == -23 || args.group == "") {
failf("group, topic, partition are required to reset offsets")
if args.reset != "" && (args.topic == "" || args.partition == fetchAllPartitions || args.group == "") {
failf("group and topic are required to reset offsets. for all partitions, run with -partition -1")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really sure about this help message.

@fgeller
Copy link
Owner

fgeller commented Apr 13, 2017

thanks a lot @disq !

i'm not working much with multi-partitioned topics so wasn't sure what the use cases are around resetting the consumer groups for multiple partitions. so thanks for providing one!

  • i think your suggestion to use an explicit -partition all parameter would be nicer - what do you think? i would probably keep the -1 as an "internal" flag, but use "all" as the user parameter, if that makes sense?

  • do you think extending the -partition parameter to also accept a comma separated list of partitions would make sense? not necessarily as part of this pr, just asking for use cases in general.

  • i'm curious: what race were you running into that you fixed in a927247?

@disq
Copy link
Contributor Author

disq commented Apr 13, 2017

Yes, I think implementing an all param would be clearer for users. Also, for specifying multiple (well, a list of) partitions, one could invoke with the -partition parameter multiple times maybe, something like kt -group g -topic t -partition 1 -partition 3 -partition 17? What do you think?

The race is, since the cmd.reset variable was getting overwritten in L189, if invoked with -reset oldest or -reset newest, groupOff and pom.MarkOffset calls are potentially made with offsets from other partitions. So not all partitions were getting set to correct offsets.

@disq
Copy link
Contributor Author

disq commented Apr 13, 2017

Few more suggestions - maybe specify the partition ID in the offset resolve message in L192, and rename the rst param to something that makes sense like resolvedOffset etc.

@fgeller
Copy link
Owner

fgeller commented Apr 15, 2017

@disq sorry, slow to respond at the moment - traveling.

  • are you interested in adding the -partition all bit, or do you want me to merge as is and then extend?
  • i think i'd prefer a single -partition argument, would parallel e.g. the -offsets parameter of the consume command if that makes sense?
  • interpolating the partition argument into the log message in L192 makes sense to me!
  • agreed, would also prefer resolvedOffset over rst

@disq
Copy link
Contributor Author

disq commented Apr 17, 2017

I'll do the -partition all bit and the param rename, and leave you with the multiple-partitions-param stuff. Haven't checked the code in detail, but it might need significant refactoring for that one.

@disq
Copy link
Contributor Author

disq commented Apr 17, 2017

Haven't had the time to test it yet, I'll report back if there's something to fix.

@disq
Copy link
Contributor Author

disq commented Apr 17, 2017

Tested, seems to work.

@fgeller
Copy link
Owner

fgeller commented Apr 17, 2017

cheers @disq !

@fgeller fgeller merged commit e8a7c48 into fgeller:master Apr 17, 2017
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.

2 participants