ntent / kafka4net

C# client for Kafka
Apache License 2.0
52 stars 32 forks source link

Producer is unable to fetch topic metadata when first kafka broker is down #16

Closed vikmv closed 9 years ago

vikmv commented 9 years ago

While working on #14, noticed one more issue.

Steps to reproduce:

My findings why this is happening:

//Cluster.ConnectAsync method:
..
initBrokers = ...; // initialized with 3 brokers, and their id=-99
..
MergeTopicMeta(initMeta);   // method is called, and there are still 3 brokers in there
..

//inside MergeTopicMeta method:

var newBrokers = topicMeta.Brokers.Except(_metadata.Brokers, BrokerMeta.NodeIdComparer).ToArray();
//newBroker is left with only 1 record (instead of 3), because all the brokers have the same Id=-99
..
_metadata.Brokers = _metadata.Brokers.Concat(newBrokers).ToArray();

So, metadata.Brokers results in adding only one broker to the list and producer is unable to fetch topic metadata from it.

vikmv commented 9 years ago

Created pull request #17 with one of possible solutions of this issue

vchekan commented 9 years ago

Thanks for reporting this. I fixed it in different manner though. I fixed the comparer, so that if it is used in other placed, this bug would not show up again.