-
Notifications
You must be signed in to change notification settings - Fork 16
handle incomplete records when parsing record batch #24
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
Conversation
0fdf9c5
to
cb1d481
Compare
This changeset relaxes the parsing of record batches when the data returned does not align exactly with the format of a record batch. We will return all successfully parsed record batches, and discard record batches that are incomplete. When specifying `max_bytes` on the fetch request, the fetch will return exactly max_bytes. If this value is less than the available data to fetc, the fetch request will potentially return an incomplete record batch. In this case, we cowardly refuse to parse the record batch. Previously we would return a match error when parsing the magic byte or deserializing the record itself. This prevented consumers from progressing once this situation occurred.
cb1d481
to
e8be52d
Compare
@dantswain Would love to get your thoughts here or more details on #23. We are trying to utilize FetchRequest/Response V5 to utilize headers in KafkaEx but we keep running into issues deserializing record batches. I think we have a temporary workaround of using |
Hi @jfmyers9 sorry for the delay. I've looked at this a couple times but it's gonna take time when I can really focus on it. My biggest concern here is losing messages - what happens to the data we drop? Not saying anything bad specifically happens, just trying to make really sure I understand and haven't had time to sit down and think it through. Also not sure why your build is failing :/ Something to do with snappy but it's not clear from the error messages what's going on. |
Yeah I agree its a bit odd, as said I would like to return the partial data in some fashion, but it's not clear to me how we'd change the API to achieve that. If you are looking for a simple test case, here is a repro that I have on my local Kafka running in docker:
|
And here is the result with this changeset:
|
Hey @dantswain, just wondering if you've had a chance to look at this? I'd love for us to be able to remove our |
@dantswain have you got chance to look at this? I've this issue on my side right now either. %Message{offset: last_offset} = List.last(message_set) |
Thanks for looking at this, @Argonus ! I trust your assessment and that makes me feel better about merging. Do I need to publish a release to hex? I'm super out of touch on the state of all of this. |
@dantswain yeah, that would be amazing. |
@Argonus this should be done, I added you to the list of owners on hex.pm as well, so you are empowered to push releases :) Thanks so much for taking this on. I didn't notice any of the messages in slack - I almost never sign in to elixirlang slack anymore :/ You can always feel free to reach out via github or via my email (dan dot t dot swain at gmail) - that's much more likely to get a response. |
This changeset relaxes the parsing of record batches when the data returned does not align exactly with the format of a record batch. We will return all successfully parsed record batches, and discard record batches that are incomplete.
When specifying
max_bytes
on the fetch request, the fetch will return exactly max_bytes. If this value is less than the available data to fetch, the fetch request will potentially return an incomplete record batch. In this case, we cowardly refuse to parse the record batch.Previously we would return a match error when parsing the magic byte or deserializing the record itself. This prevented consumers from progressing once this situation occurred.
Note: A more complete change might be to return the bytes that we were unable to parse similar to what we do in
lib/generated/fetch.ex
, but I'm unaware of how to make such a large change due to the generated code. If this approach is preferred, any guidance on how to implement this change would be helpful.Fixes #23