Skip to content

KafkaClient.send() always fails the first time, all subsequent send() calls succeed #1488

@jeffwidman

Description

@jeffwidman

The first time I call KafkaClient.send() it always immediately fails, even before I call poll(). Any subsequent calls will hang until I call poll(), then they will succeed.

This always happens on the first send() call to a new broker. So if send()/poll() are working as expected for node 1, and then I try sending to node 2, I will see the same behavior where the first call fails, then subsequent calls succeed.

Is this expected behavior or a bug?

Possibly related: #981 / #1278 / #1279

Example code:

import kafka.protocol as kp
from kafka.client_async import KafkaClient


kc = KafkaClient(bootstrap_servers=['kafka01.stg.local:9092'])

# first call to kc.send() always fails
gcr1 = kc.send(1, kp.commit.GroupCoordinatorRequest[0]('valid_group_name'))

gcr1.is_done  # always True even though I never called poll()
gcr1.failed()  # always True
gcr1.value  # `None`... the docs say this shold return a Response Struct or error?


# try it a second time:
gcr1 = kc.send(1, kp.commit.GroupCoordinatorRequest[0]('valid_group_name'))
gcr1.is_done  # always False until I call poll()

# will block until it gets a response... generally returns almost immediately
kc.poll(future=gcr1)

gcr1.value # always returns a Response struct

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions