-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Correctly handle unencodable messages in the producer #538
Conversation
What if the flag setting happened inside return error or return success? |
can we simply set the returned flag in the |
I suspect I'll end up getting rid of the flag (and the setting of the array to |
f15799e
to
8b5d6d8
Compare
Ya, setting the flag isn't right at all because it results in messages reaching the user with flags set, which breaks our API guarantee. |
Move `Key.Encode()` and `Value.Encode()` calls slightly earlier (to `groupAndFilter`) where we have access to the batch in order to be able to remove them from consideration on error. Otherwise failed messages would not be removed from the batch and could end up returned twice. Add cache members to the ProducerMessage struct to store the results until we actually need them. Fixes #449. This is perhaps not the most elegant solution. However it is correct and a better solution would be a lot more invasive. This will do in order to ship the fix in a 1.5.1 patch release.
34c6a26
to
7e88a99
Compare
I've just pushed a better (i.e. actually correct) fix to this branch. It's still not ideal architecturally, but I think I'm happy enough with it to release it as v1.5.1 if you both agree. |
This code works for me. There's something stinky about the existence of |
Understatement is a bad habit of mine :P |
👍 - this fix looks pretty straightforward to me. Side note: another good reason to remove the Encoder interface for sarama v2. :) |
Yup :) |
Correctly handle unencodable messages in the producer
I'll release 1.5.1 with this shortly and then file another ticket to refactor/solve it properly. |
1.6.1 released. |
The longer-term refactor has been rolled into #433 which has just suddenly gone from "nice to have eventually" to "reasonably important". |
Quick fix for #449, pending more thought and writing tests etc.