Skip to content

fix: poll(timeout_ms=0) returns buffered records when coordinator times out#2718

Open
HKanaparthi wants to merge 1 commit intodpkp:masterfrom
HKanaparthi:fix/poll-timeout-zero-buffered-records
Open

fix: poll(timeout_ms=0) returns buffered records when coordinator times out#2718
HKanaparthi wants to merge 1 commit intodpkp:masterfrom
HKanaparthi:fix/poll-timeout-zero-buffered-records

Conversation

@HKanaparthi
Copy link

Fixes #2692

Root cause:
When timeout_ms=0, coordinator.poll() returns False immediately, causing
an early return {} at line 722 that skipped the fetched_records() buffer
check — so buffered messages from previous poll calls were silently dropped.

Fix:
Added a buffer check inside the early-exit branch so already-fetched
records are still returned even when the coordinator times out.
Non-blocking behavior is fully preserved.

Tests:
Added 2 regression tests covering:

  • poll(timeout_ms=0) returns buffered records when coordinator times out
  • poll(timeout_ms=0) returns empty when no records are buffered

Note: Tests use mocks. Happy to add integration tests if needed.

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.

KafkaConsumer.poll() does not poll messages with default value for timeout_ms

1 participant