jack2012aa commented on code in PR #21197:
URL: https://github.com/apache/kafka/pull/21197#discussion_r2641740372
##########
core/src/main/scala/kafka/network/SocketServer.scala:
##########
@@ -1154,6 +1157,10 @@ private[kafka] class Processor(
def accept(socketChannel: SocketChannel,
mayBlock: Boolean,
acceptorBlockedPercentMeter: com.yammer.metrics.core.Meter):
Boolean = {
+ // reject new connections if the processor is shutting down
+ if (!shouldRun.get())
Review Comment:
The race condition still exists when the `Processor` is closed after the get
and before the connection is built.
##########
core/src/main/scala/kafka/network/SocketServer.scala:
##########
@@ -731,8 +731,11 @@ private[kafka] abstract class Acceptor(val socketServer:
SocketServer,
s" sendBufferSize [actual|requested]:
[${socketChannel.socket.getSendBufferSize}|$sendBufferSize]" +
s" recvBufferSize [actual|requested]:
[${socketChannel.socket.getReceiveBufferSize}|$recvBufferSize]")
true
- } else
+ } else{
+ // connection was rejected (likely due to processor shutdown) - close
the socket.
+ connectionQuotas.closeChannel(this,
ListenerName.normalised(endPoint.listener), socketChannel)
Review Comment:
`Processor#accept` may return false because its `newConnections` queue is
full. In this case, closing the channel here blocks other processors from
accepting the channel.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]