Producer.poll(timeout) blocks for full timeout after delivery callback fires (regression in 2.13.0)
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
- #2297 @wgu9 による — マージされずにクローズ
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
調査の方向性
src/confluent_kafka/src/Producer.c の Producer_poll0 から開始し、その wakeable loop と Consumer.poll() の実装を比較してください。指定されたバージョンに対して、提供されている producer.poll(5.0) の再現を実行し、delivery callback が実行された直後に poll が戻り、タイムアウト全体を使い切らないことを確認してください。
索引モデルが issue の本文から書いたものです。
説明
Description
Producer.poll(timeout) no longer returns early after processing delivery callbacks when timeout > 200ms. Instead it blocks for the entire timeout duration, regardless of whether events were served.
This is a regression introduced in 2.13.0 by the "wakeable poll" refactor (PR #2126 ). The original single-call implementation of rd_kafka_poll() returned as soon as events were processed. The new chunked loop replicates this correctly for Consumer.poll() but not for Producer.poll().
The producer loop accumulates chunk_result but never breaks when chunk_result > 0, causing it to exhaust all remaining chunks even after the delivery callback has fired.
Step to reproduce
import time
from confluent_kafka import Producer, __version__
KAFKA_BOOTSTRAP = "localhost:9092"
POLL_TIMEOUT = 5.0
print(f"confluent-kafka version: {__version__}")
producer = Producer({"bootstrap.servers": KAFKA_BOOTSTRAP})
def on_delivery(err, msg):
print(f" [{time.time():.3f}] on_delivery fired — err={err}, topic={msg.topic()}")
print(f"[{time.time():.3f}] produce()")
producer.produce("test-topic", value=b"hello", on_delivery=on_delivery)
print(f"[{time.time():.3f}] poll({POLL_TIMEOUT}) start")
t0 = time.time()
producer.poll(POLL_TIMEOUT)
elapsed = time.time() - t0
print(f"[{time.time():.3f}] poll() returned after {elapsed:.3f}s")
Output in 2.12.2
confluent-kafka version: 2.12.2
[1733305268.206] produce()
[1733305268.206] poll(5.0) start
[1733305268.532] on_delivery fired — err=None, topic=test-topic
[1733305268.532] poll() returned after 0.325s
Output in 2.13.2
confluent-kafka version: 2.13.2
[1733305281.264] produce()
[1733305281.265] poll(5.0) start
[1733305281.276] on_delivery fired — err=None, topic=test-topic
[1733305286.078] poll() returned after 4.813s
Potential Cause
In Producer_poll0 (src/confluent_kafka/src/Producer.c), the wakeable loop does not break when chunk_result > 0
Potential fix
Add an early exit in Producer_poll0 after events are served, matching the original rd_kafka_poll() single-call behaviour and the consumer implementation:
int chunk_result = rd_kafka_poll(self->rk, chunk_timeout_ms);
if (chunk_result < 0) { r = chunk_result; break; }
r += chunk_result;
if (chunk_result > 0) break; // ← return early once events are served
The new chunked implementation was intended to preserve this early-exit behaviour while adding signal interruptibility. It does so correctly for Consumer.poll() (if (rkm) break;) but the equivalent guard was omitted in Producer_poll0, making poll(5.0) in 2.13.x strictly worse than poll(5.0) in 2.12.x when the broker is fast.
Environment
- confluent-kafka-python: 2.13.0, 2.13.1, 2.13.2
- Python: 3.11+
- OS: Linux
Thanks to the maintainers for the great work on confluent kafka. Happy to open a PR with the proposed fix if the issue is
confirmed.
- 主要言語
- Python
- スター
- 528
- フォーク
- 977
- 平均マージ
- 2日 19時間
- マージ済み PR(30日)
- 19
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
confluentinc/confluent-kafka-python のほかの issue
-
KIP-848 migration guide says never use assign()/unassign() with group.protocol='consumer'; it's only rejected after subscribe対応中かも @hidingmyname が 22 日前に担当しました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
confluentinc/confluent-kafka-python#2405 ·
メンテナーはふだん 3 日以内に返信
-
init_transactions docstring says the transaction.timeout.ms clock starts there; it starts at begin_transaction対応中かも @hidingmyname が 22 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 91/100
confluentinc/confluent-kafka-python#2404 ·
メンテナーはふだん 3 日以内に返信
-
Wrong type annotations for read only mapping types.対応中かも @RasmusNygren が 198 日前に担当しました。 オープンstatus:under-review
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
confluentinc/confluent-kafka-python#2244 ·
メンテナーはふだん 3 日以内に返信
-
Wrong signature for `KafkaError`'s 1st parameter in `.pyi`対応中かも @wgu9 が 159 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
confluentinc/confluent-kafka-python#2243 ·
メンテナーはふだん 3 日以内に返信
-
Use joserfc instead of authlib.jose対応中かも @yvaishalirao が 135 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
confluentinc/confluent-kafka-python#2242 · コメント 2 件 ·
メンテナーはふだん 3 日以内に返信
confluentinc/confluent-kafka-python の issue をすべて見る
似ている issue
-
needs-triage
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
flashinfer-ai/flashinfer#9803 ·
メンテナーはふだん 1 日以内に返信
-
bug frontend good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
oscarbol09/thesisforge#61 ·
-
api bug performance
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
oscarbol09/audiobard#159 ·
-
area:web p2 product:business triage:active type:bug
難易度 1/5 1時間未満 初心者へのやさしさ 89/100
cuadrao-ai/argus#2328 ·
メンテナーはふだん 1 日以内に返信
-
bug frontend good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
nikhilb2/simple_invoicing#907 ·