Repository navigation
Consumer: keep raising record errors instead of spinning in poll() - #3196
Open
waw666waw666 wants to merge 1 commit into
Open
waw666waw666 wants to merge 1 commit into
waw666waw666 wants to merge 1 commit into
Conversation
When a deserializer (or a per-record CRC check) failed in the middle of a fetched batch, the error was raised once and the record generator was left exhausted but still in line. The next poll() then looped forever in fetched_records(), taking no records and never returning, regardless of timeout_ms. Keep raising the same error until the partition records are drained, and skip records below the fetch offset before validating or deserializing them, so seeking past a bad record in the middle of a batch lets the consumer continue.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If a
value_deserializer/key_deserializerraises (or a per-record CRC check fails) in the middle of a fetched batch, the consumer gets stuck on the nextpoll():PartitionRecords.take()raises the stored error once, but the record generator has already terminated with that exception. The partition records are still truthy and still in line at the current position, sofetched_records()keeps calling_append(), which takes 0 records each time, andwhile records_remaining > 0never ends.The usual way out is to seek past the bad record, but that didn't work either when the record sits in the middle of a batch. The broker returns the whole batch again, and the records below the fetch offset were only skipped (
dropwhile) after they had been CRC-checked and deserialized, so the same record failed again.This change:
PartitionRecordsand raises it on everytake()until the records are drained (for example afterseek()), which matches the Java client;_unpack_records, before validation and deserialization.The behaviour has been there since the inline-exception handling was added in 2.2.0.
Tests:
test__unpack_records_corruptednow checks that the error is raised again; new tests cover the repeated deserializer error at thePartitionRecordsandfetched_records()level (the latter hangs without the fix, so it has a 10s timeout) and seeking past a bad record in the middle of a batch. All four fail on master and pass with the change. Fullpytest test: 2762 passed, 68 skipped;pylint --errors-only kafka testclean.