-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Help: KafkaConsumer iterator ignores consumer_timeout_ms if entire cluster is down #1322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I have also found that kafkaConsumer iterator ignores consumer_timeout_ms if consumer assigns to a non exist topic. It seems to the same question. |
I experience the same thing. And the loop makes CPU go to 100%. |
@RechardTheGrey I can't reproduce this with the latest release. Have you tried upgrading? |
I am experiencing the same problem, and here is the step to reproduce: First, save this piece of code to from kafka import KafkaProducer, KafkaConsumer
import time
config = {
'bootstrap_servers': 'localhost:9092',
'group_id': 'test',
'consumer_timeout_ms': 1000
}
consumer = KafkaConsumer('test-consumer', **config)
while True:
for message in consumer:
print(message)
print('no message') Second, start a kafka server, create a topic named Third, kill the kafka server. Turn back to your terminal, you will see there is no more So I followed the code of kafka-python, and finally I stepped into here. I found the fact that the only condition to break the infinite loop is to have the future variable set to None or change the future.is_done to True, but there is not any code to modify the future variable. Maybe the call stack would help you:
And thank you for this great opensource project, you are doing a great job. |
After testing, I found a surprise. It will block, until the cluster is back. |
Hi!
Forgive my poor English, but I need your help. @dpkp
While stress testing Kafka, I have found that comsumer can block forever when all brokers down. After all brokers down, comsumer will fall into a loop to getting metadata from broker. This loop will never break util one or more brokers restart.
Is there a way that consumer can break this loop? I do not want block here, I want to do some other things when brokers down.
my code is like this:
After consumer block, I got this when keyboardInterrupt:

other infos:
kafka_python-1.3.2
python2.6.3
kafka_2.11-0.10.2.1
The text was updated successfully, but these errors were encountered: