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

Compressed size is not used for validating message in producer when compression is enabled #2142

Closed
parikdepa opened this issue Feb 11, 2022 · 3 comments · May be fixed by #2892
Closed

Compressed size is not used for validating message in producer when compression is enabled #2142

parikdepa opened this issue Feb 11, 2022 · 3 comments · May be fixed by #2892

Comments

@parikdepa
Copy link

parikdepa commented Feb 11, 2022

Versions

Sarama Version : v1.29.1
Go version: 1.13

Configuration

What configuration values are you using for Sarama and Kafka?

Producer.Compression = sarama.CompressionGZIP
Producer.MaxMessageBytes = 2097164
Logs

kafka: Failed to produce message to topic: kafka server: Message was too large, server rejected it to avoid allocation error.

Problem Description

Even after setting producer compression by default to sarama.CompressionGZIP. We are noticing in asyn_producer.go message byte size validation checks against uncompressed message even though Kafka broker allows compressed message based on max size settings . This is cause issues sending message that has very low compressed size compared to uncompressed message. Can we get some help on it?
https://github.com/Shopify/sarama/blob/6693712f54b76066ea239255c30585832983947d/async_producer.go#L367

@parikdepa
Copy link
Author

Any updates on this issue? Thanks

@dnwe
Copy link
Collaborator

dnwe commented May 11, 2022

@parikdepa the issue is correct, unfortunately Sarama does a local compare of the pre-compression bytes, and it's probably non-trivial to fix at the moment.

However, this was always (as far as I know) a convenient client-side safety net, and the remote kafka cluster will reject the produce request if you send a compressed message that it is larger than the configured maximum size that it can accept. You could just set Producer.MaxMessageBytes = sarama.MaxRequestSize and you're unlikely to see any ill effects.

@github-actions

This comment was marked as outdated.

@github-actions github-actions bot added the stale Issues and pull requests without any recent activity label Aug 18, 2023
@dnwe dnwe removed the stale Issues and pull requests without any recent activity label Aug 18, 2023
@dnwe dnwe closed this as completed Aug 18, 2023
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 a pull request may close this issue.

2 participants