Producer.poll(timeout) blocks for full timeout after delivery callback fires (regression in 2.13.0)
Los mantenedores suelen responder en 3 días
Nadie ha tomado este issue todavía.
- #2297 de @wgu9 — cerrado sin fusionar
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
Línea de trabajo
Comienza en src/confluent_kafka/src/Producer.c, en Producer_poll0, y compara su bucle que puede despertarse con la implementación de Consumer.poll(). Ejecuta la reproducción proporcionada de producer.poll(5.0) con las versiones indicadas y verifica que poll retorne poco después de que se ejecute el callback de entrega, en lugar de consumir todo el tiempo de espera.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 528
- Forks
- 977
- Merge medio
- 2 d 19 h
- PR fusionados (30 d)
- 19
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de confluentinc/confluent-kafka-python
-
KIP-848 migration guide says never use assign()/unassign() with group.protocol='consumer'; it's only rejected after subscribePosiblemente ocupada @hidingmyname la tomó hace 22 días. Abierto
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
confluentinc/confluent-kafka-python#2405 ·
Los mantenedores suelen responder en 3 días
-
init_transactions docstring says the transaction.timeout.ms clock starts there; it starts at begin_transactionPosiblemente ocupada @hidingmyname la tomó hace 22 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 91/100
confluentinc/confluent-kafka-python#2404 ·
Los mantenedores suelen responder en 3 días
-
Wrong type annotations for read only mapping types.Posiblemente ocupada @RasmusNygren la tomó hace 198 días. Abiertostatus:under-review
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
confluentinc/confluent-kafka-python#2244 ·
Los mantenedores suelen responder en 3 días
-
Wrong signature for `KafkaError`'s 1st parameter in `.pyi`Posiblemente ocupada @wgu9 la tomó hace 159 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
confluentinc/confluent-kafka-python#2243 ·
Los mantenedores suelen responder en 3 días
-
Use joserfc instead of authlib.josePosiblemente ocupada @yvaishalirao la tomó hace 135 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
confluentinc/confluent-kafka-python#2242 · 2 comentarios ·
Los mantenedores suelen responder en 3 días
Todos los issues de confluentinc/confluent-kafka-python
Issues similares
-
needs-triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
flashinfer-ai/flashinfer#9803 ·
Los mantenedores suelen responder en 1 día
-
bug frontend good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
oscarbol09/thesisforge#61 ·
-
api bug performance
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
oscarbol09/audiobard#159 ·
-
area:web p2 product:business triage:active type:bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 89/100
cuadrao-ai/argus#2328 ·
Los mantenedores suelen responder en 1 día
-
bug frontend good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
nikhilb2/simple_invoicing#907 ·