1
votes

How do I permanently remove a broker from a Kafka cluster?

Scenario:

I have a stable cluster of 3 brokers. I temporarily added a fourth broker that successfully joined the cluster. The controller returned metadata indicating this broker was part of the cluster.

However, I never rebalanced partitions onto this broker, so this broker #4 was never actually used.

I later decided to remove this unused broker from the cluster. I shutdown the broker successfully and Zookeeper /broker/ids no longer lists broker #4.

However, when our application code connects to any Kafka broker and fetches metadata, we get a broker list that includes this deleted broker.

How do I indicate to the cluster that this broker has been permanently removed from the cluster and not just a transient downtime?

Additionally, what's happening under the covers that causes this?

I'm guessing that when I connect to a broker and ask for metadata, the broker checks its local cache for the controller ID, contacts the broker and asks it for the list of all brokers. Then the controller checks it's cached list of brokers and returns the list of all brokers known to have belonged to the cluster at any point in time.

I'm guessing this happens because it's not certain if the dead broker is permanently removed or just transient downtime. So I'm thinking we just need to indicate to the controller that it needs to reset it's list of known cluster brokers to the known live brokers in zookeeper. But would not be surprised if something in my mental model is incorrect.

This is for Kafka 0.8.2. I am planning to upgrade to 0.10 soon, so if 0.10 handles this differently, I'd also love to know that.

1
/broker/ids no longer lists broker #4. It should not happened since #4 already deregister from /broker/ids, I never found this issue in 0.9Shawn Guo
Have you tried restarting all your consumers after shutting down the #4 broker?Rakesh Rakshit
Yes, our consumer code also cached the down broker, so we made sure to restart those. But even on fresh start they are still getting outdated metadata from the broker.Jeff Widman

1 Answers

1
votes

It looks like this is most likely due to this bug in Kafka 8, which was fixed in Kafka 9.