In some of our Kafka 0.10.2.0 tests, we spin up multiple brokers (`KafkaServerStartable`s). However, when shutting them down (in reverse order of starting them up), we run into the following error in the teardown:
kafka.common.StateChangeFailedException: encountered error while electing leader for partition [_schemas,0] due to: No other replicas in ISR 0 for [_schemas,0] besides shutting down brokers 0.
at kafka.controller.PartitionStateMachine.electLeaderForPartition(PartitionStateMachine.scala:362) [kafka_2.11-0.10.2.0-cp1.jar:na]
at kafka.controller.PartitionStateMachine.kafka$controller$PartitionStateMachine$$handleStateChange(PartitionStateMachine.scala:202) [kafka_2.11-0.10.2.0-cp1.jar:na]
at kafka.controller.PartitionStateMachine$$anonfun$handleStateChanges$2.apply(PartitionStateMachine.scala:141) [kafka_2.11-0.10.2.0-cp1.jar:na]
at kafka.controller.PartitionStateMachine$$anonfun$handleStateChanges$2.apply(PartitionStateMachine.scala:140) [kafka_2.11-0.10.2.0-cp1.jar:na]
at scala.collection.immutable.Set$Set1.foreach(Set.scala:94) [scala-library-2.11.8.jar:na]
at kafka.controller.PartitionStateMachine.handleStateChanges(PartitionStateMachine.scala:140) [kafka_2.11-0.10.2.0-cp1.jar:na]
at kafka.controller.KafkaController$$anonfun$shutdownBroker$3$$anonfun$apply$1$$anonfun$apply$mcV$sp$3.apply(KafkaController.scala:268) [kafka_2.11-0.10.2.0-cp1.jar:na]
So our tests pass, but an error is thrown in the teardown code, so CI fails.
My understanding is that because `controlled.shutdown.enable` defaults to `true`, every time we shut down a broker Kafka tries to move partition leaders to remaining brokers. When it's on the last broker, there's nowhere else to move, so it throws an error.
We're able to get around this by setting `controlled.shutdown.enable` to `false`, which should be fine for testing. However, we then end up getting a lot of warnings such as:
16:20:18.844 [Controller-0-to-broker-2-send-thread] WARN kafka.controller.RequestSendThread - [Controller-0-to-broker-2-send-thread], Controller 0's connection to broker localhost:9094 (id: 2 rack: null) was unsuccessful
java.io.IOException: Connection to localhost:9094 (id: 2 rack: null) failed
at kafka.utils.NetworkClientBlockingOps$.awaitReady$1(NetworkClientBlockingOps.scala:84) ~[kafka_2.11-0.10.2.0-cp1.jar:na]
at kafka.utils.NetworkClientBlockingOps$.blockingReady$extension(NetworkClientBlockingOps.scala:94) ~[kafka_2.11-0.10.2.0-cp1.jar:na]
at kafka.controller.RequestSendThread.brokerReady(ControllerChannelManager.scala:232) [kafka_2.11-0.10.2.0-cp1.jar:na]
at kafka.controller.RequestSendThread.liftedTree1$1(ControllerChannelManager.scala:185) [kafka_2.11-0.10.2.0-cp1.jar:na]
at kafka.controller.RequestSendThread.doWork(ControllerChannelManager.scala:184) [kafka_2.11-0.10.2.0-cp1.jar:na]
at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:63) [kafka_2.11-0.10.2.0-cp1.jar:na]
Is setting `controlled.shutdown.enable` to `false` the right thing to do for testing? If so, is there a way to stop spamming these warnings as above?