-
Notifications
You must be signed in to change notification settings - Fork 16
kafka consumer: Limit MaxBrokerReadBytes
#606
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
kafka consumer: Limit MaxBrokerReadBytes
#606
Conversation
Limits the `MaxBrokerReadBytes` and `MaxFetchBytes` to the maximum value that is accepted by `franz-go` library. Signed-off-by: Marc Lopez Rubio <marc5.12@outlook.com>
kafka/consumer.go
Outdated
| } | ||
| } | ||
| if cfg.BrokerMaxReadBytes < 0 || cfg.BrokerMaxReadBytes > 1<<30 { | ||
| cfg.BrokerMaxReadBytes = 1 << 30 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: shouldn't we return an error if the value is invalid like we did for other options ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My rationale was that it's useful to have this limited to the max amount, since it's quite large. But perhaps we should log an info message that this is being done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on setting to the max and logging a warning. But in alignment with @kruskall 's concerns, I don't see why this should be treated different than FetchMinBytes, MaxPollBytes and MaxPollPartitionBytes (https://github.com/elastic/apm-queue/pull/606/files#diff-bd03622ad29aac2f6cffdf1c2755ccffd0981f3e4ffef219508a265509f4fe8eR144-R152) - should we also set these to 0 if negative, and log warnings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marclop I'm not sure I follow your approach to the latest change. What I tried to suggest in the above message is to go further with your approach and also align the existing code to issue log messages and set config values to the franz-kafka minimum or maximum for existing config options such as FetchMinBytes, MaxPollBytes and MaxPollPartitionBytes. I did not mean to suggest to issue an error for negative settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do MaxPollBytes and MaxPollPartitionBytes. But FetchMinBytes doesn't really have an upper limit. We can set one arbitrarily if we wish, but I'd rather not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 0544375
Signed-off-by: Marc Lopez Rubio <marc5.12@outlook.com>
| cfg.Logger.Info("kafka: BrokerMaxReadBytes exceeds 1GiB, setting to 1GiB") | ||
| cfg.BrokerMaxReadBytes = 1 << 30 | ||
| } | ||
| if cfg.MaxPollBytes > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also validate that BrokerMaxReadBytes is GTE than MaxPollBytes and set it to the bigger value otherwise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't that what the code block above does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, what I mean right now it's possible to set BrokerMaxReadBytes=1 and MaxPollBytes=1000000 and we will accept this configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah good catch, added some more validation and tests.
Signed-off-by: Marc Lopez Rubio <marc5.12@outlook.com>
Signed-off-by: Marc Lopez Rubio <marc5.12@outlook.com>
Signed-off-by: Marc Lopez Rubio <marc5.12@outlook.com>
Limits the
MaxBrokerReadBytesandMaxFetchBytesto the maximum value that is accepted byfranz-golibrary.