Skip to content

Commit 21a5ca8

Browse files
author
Dana Powers
committed
Catch ReplicaNotAvailableError in MetadataResponse -- per kafka-devs, this error can and should be ignored
1 parent 8a5fe31 commit 21a5ca8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

kafka/client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
ConnectionError, FailedPayloadsError,
1212
KafkaTimeoutError, KafkaUnavailableError,
1313
LeaderNotAvailableError, UnknownTopicOrPartitionError,
14-
NotLeaderForPartitionError)
14+
NotLeaderForPartitionError, ReplicaNotAvailableError)
1515

1616
from kafka.conn import collect_hosts, KafkaConnection, DEFAULT_SOCKET_TIMEOUT_SECONDS
1717
from kafka.protocol import KafkaProtocol
@@ -350,6 +350,11 @@ def load_metadata_for_topics(self, *topics):
350350
log.error('No leader for topic %s partition %d', topic, partition)
351351
self.topics_to_brokers[topic_part] = None
352352
continue
353+
# If one of the replicas is unavailable -- ignore
354+
# this error code is provided for admin purposes only
355+
# we never talk to replicas, only the leader
356+
except ReplicaNotAvailableError:
357+
log.warning('Some (non-leader) replicas not available for topic %s partition %d', topic, partition)
353358

354359
# If Known Broker, topic_partition -> BrokerMetadata
355360
if leader in self.brokers:

0 commit comments

Comments
 (0)