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

Reinforce kafka msg size guards #87

Merged
merged 1 commit into from
Nov 18, 2024
Merged

Conversation

eminano
Copy link
Collaborator

@eminano eminano commented Nov 18, 2024

Currently there's a guard in place to make sure there are no messages sent to kafka that go over the limit in size. However, the check is only accounting for the serialised bytes of the value in the message, but not for the rest of the message (headers, metadata...). This PR updates the size check to ensure we leave some buffer to account for those extra parts of the message, discarding the message and logging it as data loss if the value is more than 95% of the limit.

An error log is added to identify when the send thread stops unexpectedly due to kafka errors.

@eminano eminano requested a review from exekias November 18, 2024 13:18
Copy link
Member

@exekias exekias left a comment

Choose a reason for hiding this comment

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

I believe we can merge this as it is, left a comment on the approach, but I don't have a better one :)

if len(walDataBytes) > int(w.maxBatchBytes) {
// check if walEventBytes is larger than 95% of the Kafka accepted max
// message size to allow for some buffer for the rest of the message
if len(walDataBytes) > int(0.95*float64(w.maxBatchBytes)) {
Copy link
Member

Choose a reason for hiding this comment

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

this is probably good enough, although it can be a lot of buffer for high max bytes settings, I wonder if there is a predictable payload size math (ie 100bytes padding)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll have a think/look.

@eminano eminano merged commit 8fe9ff7 into main Nov 18, 2024
5 checks passed
@eminano eminano deleted the reinforce-max-kafka-msg-size branch November 18, 2024 14:29
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