{"action":"closed","issue":{"url":"https://api.github.com/repos/dpkp/kafka-python/issues/422","labels_url":"https://api.github.com/repos/dpkp/kafka-python/issues/422/labels{/name}","comments_url":"https://api.github.com/repos/dpkp/kafka-python/issues/422/comments","events_url":"https://api.github.com/repos/dpkp/kafka-python/issues/422/events","html_url":"https://github.com/dpkp/kafka-python/issues/422","id":92664429,"number":422,"title":"ensure_topic_exists : kafka_python-0.9.4-py2.7.egg/kafka/common.py:233: UnknownError","user":{"login":"jamesblackburn","id":55716,"avatar_url":"https://avatars.githubusercontent.com/u/55716?v=3","gravatar_id":"","url":"https://api.github.com/users/jamesblackburn","html_url":"https://github.com/jamesblackburn","followers_url":"https://api.github.com/users/jamesblackburn/followers","following_url":"https://api.github.com/users/jamesblackburn/following{/other_user}","gists_url":"https://api.github.com/users/jamesblackburn/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesblackburn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesblackburn/subscriptions","organizations_url":"https://api.github.com/users/jamesblackburn/orgs","repos_url":"https://api.github.com/users/jamesblackburn/repos","events_url":"https://api.github.com/users/jamesblackburn/events{/privacy}","received_events_url":"https://api.github.com/users/jamesblackburn/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-02T15:24:47Z","updated_at":"2016-01-30T19:00:09Z","closed_at":"2016-01-30T19:00:09Z","body":"I'm seeing an issue where ```ensure_topic_exists``` fails with an ```UnknownError```.\r\n\r\nThis occurs in integration tests which spin up a kafka, connect a kafka-python ```KafkaClient``` to it, then call ```ensure_topic_exists``` before the broker is read (I guess).\r\n\r\nError from kafka_python:\r\n\r\n```\r\n/users/is/ahlpypi/egg_cache/k/kafka_python-0.9.4-py2.7.egg/kafka/consumer/base.py:51: in __init__\r\n    self.client.load_metadata_for_topics(topic)\r\n/users/is/ahlpypi/egg_cache/k/kafka_python-0.9.4-py2.7.egg/kafka/client.py:378: in load_metadata_for_topics\r\n    kafka.common.check_error(topic_metadata)\r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r\n\r\nresponse = TopicMetadata(topic='tests_integration_scripts_test_mkd_kafka2mongo_test_daterange_empty_queue', error=5, partitions=[])\r\n\r\n    def check_error(response):\r\n        if isinstance(response, Exception):\r\n            raise response\r\n        if response.error:\r\n            error_class = kafka_errors.get(response.error, UnknownError)\r\n>           raise error_class(response)\r\nE           LeaderNotAvailableError: TopicMetadata(topic='tests_integration_scripts_test_mkd_kafka2mongo_test_daterange_empty_queue', error=5, partitions=[])\r\n\r\n/users/is/ahlpypi/egg_cache/k/kafka_python-0.9.4-py2.7.egg/kafka/common.py:233: LeaderNotAvailableError\r\n```\r\n\r\nSometimes I see the following error in kafka:\r\n\r\n```\r\ntests/integration/test_feed.py [2015-06-30 22:59:22,786] ERROR [KafkaApi-0] error when handling request Name: TopicMetadataRequest; Version: 0; CorrelationId: 2; ClientId: pyclient; Topics: tests_integration_test_feed_test_starts_ok_with_empty_snapshot_queue (kafka-request-handler-3 KafkaApis)\r\nkafka.admin.AdminOperationException: replication factor: 1 larger than available brokers: 0\r\nat kafka.admin.AdminUtils$.assignReplicasToBrokers(AdminUtils.scala:70)\r\nat kafka.admin.AdminUtils$.createTopic(AdminUtils.scala:171)\r\nat kafka.server.KafkaApis$$anonfun$19.apply(KafkaApis.scala:520)\r\nat kafka.server.KafkaApis$$anonfun$19.apply(KafkaApis.scala:503)\r\nat scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)\r\nat scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)\r\nat scala.collection.immutable.Set$Set1.foreach(Set.scala:79)\r\nat scala.collection.TraversableLike$class.map(TraversableLike.scala:245)\r\nat scala.collection.AbstractSet.scala$collection$SetLike$$super$map(Set.scala:47)\r\nat scala.collection.SetLike$class.map(SetLike.scala:92)\r\nat scala.collection.AbstractSet.map(Set.scala:47)\r\nat kafka.server.KafkaApis.getTopicMetadata(KafkaApis.scala:503)\r\nat kafka.server.KafkaApis.handleTopicMetadataRequest(KafkaApis.scala:542)\r\nat kafka.server.KafkaApis.handle(KafkaApis.scala:62)\r\nat kafka.server.KafkaRequestHandler.run(KafkaRequestHandler.scala:59)\r\nat java.lang.Thread.run(Thread.java:724)\r\n[2015-06-30 22:59:22,794] INFO [Kafka Server 0], started (main KafkaServer)\r\n[2015-06-30 22:59:22,854] INFO New leader is 0 (ZkClient-EventThread-11-localhost:65535 ZookeeperLeaderElector$LeaderChangeListener)\r\n[2015-06-30 22:59:22,857] INFO [BrokerChangeListener on Controller 0]: Broker change listener fired for path /brokers/ids with children 0 (ZkClient-EventThread-11-localhost:65535 ReplicaStateMachine$BrokerChangeListener)\r\nE.INFO:root:Release zookeeper lock\r\n```"}}