Skip to content

[Backport 7.78.x] kafka_actions: Return early when end of partition is reached#23005

Open
dd-octo-sts[bot] wants to merge 1 commit into7.78.xfrom
backport-23004-to-7.78.x
Open

[Backport 7.78.x] kafka_actions: Return early when end of partition is reached#23005
dd-octo-sts[bot] wants to merge 1 commit into7.78.xfrom
backport-23004-to-7.78.x

Conversation

@dd-octo-sts
Copy link
Contributor

@dd-octo-sts dd-octo-sts bot commented Mar 20, 2026

Backport 50338a5 from #23004.


Summary

  • Break immediately when consumer.poll() returns None (no more messages available) instead of continuing to poll until the global timeout
  • Fix _PARTITION_EOF check to use KafkaError instead of KafkaException (the constant lives on KafkaError)

🤖 Generated with Claude Code

* Return early from Kafka consume_messages when partition end is reached

Instead of waiting until the global timeout, break immediately when
poll() returns None or when all assigned partitions report EOF. This
makes the read_messages action fast when there are no more messages
to consume.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Add changelog entry for kafka_actions early return fix

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Simplify early return tests to 2 concise tests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Remove enable.partition.eof and EOF tracking — just break on None

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
(cherry picked from commit 50338a5)
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c3638d4e34

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 274 to +276
if msg is None:
continue
self.log.debug("Poll returned None (no more messages available), stopping consumption")
break

Choose a reason for hiding this comment

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

P1 Badge Preserve the configured timeout when poll() is idle

In KafkaActionsClient.consume_messages, Consumer.poll() returning None only means the 1-second poll_timeout elapsed without a record, not that the topic is exhausted. _action_read_messages still passes the user-configured timeout_ms into this generator, so on sparse topics or producers slower than 1 msg/s this change exits after the first idle second instead of waiting for the remaining timeout and can miss messages that arrive later within the requested window.

Useful? React with 👍 / 👎.

@codecov
Copy link

codecov bot commented Mar 20, 2026

Codecov Report

❌ Patch coverage is 94.73684% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (7.78.x@ca5e7d2). Learn more about missing BASE report.

Additional details and impacted files
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants