Skip to content

Conversation

@marclop
Copy link
Contributor

@marclop marclop commented Dec 5, 2024

Limits the MaxBrokerReadBytes and MaxFetchBytes to the maximum value that is accepted by franz-go library.

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>
@marclop marclop requested a review from a team as a code owner December 5, 2024 08:08
}
}
if cfg.BrokerMaxReadBytes < 0 || cfg.BrokerMaxReadBytes > 1<<30 {
cfg.BrokerMaxReadBytes = 1 << 30
Copy link
Member

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 ?

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor

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.

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 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.

Copy link
Contributor Author

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>
@marclop marclop requested review from kruskall and simitt December 6, 2024 05:14
@marclop marclop enabled auto-merge (squash) December 6, 2024 05:16
cfg.Logger.Info("kafka: BrokerMaxReadBytes exceeds 1GiB, setting to 1GiB")
cfg.BrokerMaxReadBytes = 1 << 30
}
if cfg.MaxPollBytes > 0 {
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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>
@marclop marclop requested a review from 1pkg December 10, 2024 01:31
@marclop marclop merged commit cc45977 into main Dec 10, 2024
6 checks passed
@marclop marclop deleted the f/add-MaxFetchBytes-and-MaxBrokerReadBytes-limits branch December 10, 2024 01:48
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.

5 participants