mirror of https://github.com/apache/kafka.git
KAFKA-749 Bug in socket server shutdown logic makes the broker hang on shutdown until it has to be killed; reviewed by Sriram and Jay Kreps
This commit is contained in:
parent
aed6c3c031
commit
826f02a74e
|
|
@ -126,6 +126,10 @@ class RequestChannel(val numProcessors: Int, val queueSize: Int) extends KafkaMe
|
|||
def addResponseListener(onResponse: Int => Unit) {
|
||||
responseListeners ::= onResponse
|
||||
}
|
||||
|
||||
def shutdown() {
|
||||
requestQueue.clear
|
||||
}
|
||||
}
|
||||
|
||||
object RequestMetrics {
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ class SocketServer(val brokerId: Int,
|
|||
acceptor.shutdown()
|
||||
for(processor <- processors)
|
||||
processor.shutdown()
|
||||
requestChannel.shutdown
|
||||
info("shut down completely")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class KafkaRequestHandler(id: Int, brokerId: Int, val requestChannel: RequestCha
|
|||
while(true) {
|
||||
try {
|
||||
val req = requestChannel.receiveRequest()
|
||||
if(req eq RequestChannel.AllDone){
|
||||
if(req eq RequestChannel.AllDone) {
|
||||
trace("receives shut down command, shut down".format(brokerId, id))
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,6 +110,8 @@ class KafkaServer(val config: KafkaConfig, time: Time = SystemTime) extends Logg
|
|||
info("shutting down")
|
||||
val canShutdown = isShuttingDown.compareAndSet(false, true);
|
||||
if (canShutdown) {
|
||||
if(socketServer != null)
|
||||
Utils.swallow(socketServer.shutdown())
|
||||
if(requestHandlerPool != null)
|
||||
Utils.swallow(requestHandlerPool.shutdown())
|
||||
Utils.swallow(kafkaScheduler.shutdown())
|
||||
|
|
@ -119,8 +121,6 @@ class KafkaServer(val config: KafkaConfig, time: Time = SystemTime) extends Logg
|
|||
Utils.swallow(kafkaZookeeper.shutdown())
|
||||
if(replicaManager != null)
|
||||
Utils.swallow(replicaManager.shutdown())
|
||||
if(socketServer != null)
|
||||
Utils.swallow(socketServer.shutdown())
|
||||
if(logManager != null)
|
||||
Utils.swallow(logManager.shutdown())
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue