Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,13 @@ private void receiveMessage(ByteBuf message) {
packetReceived(4 + bb.remaining());

ZooKeeperServer zks = this.zkServer;
if (zks == null || !zks.isRunning()) {

if (zks == null) {
throw new IOException("ZK down");
} else if (!zks.isRunning()){
LOG.debug("Zks not running but keep processing");
}

if (initialized) {
// TODO: if zks.processPacket() is changed to take a ByteBuffer[],
// we could implement zero-copy queueing.
Expand Down Expand Up @@ -521,11 +525,11 @@ private void receiveMessage(ByteBuf message) {
throw new IOException("Len error " + len);
}
ZooKeeperServer zks = this.zkServer;
if (zks == null || !zks.isRunning()) {
throw new IOException("ZK down");

if (zks != null && zks.isRunning()) {
// checkRequestSize will throw IOException if request is rejected
zks.checkRequestSizeWhenReceivingMessage(len);
}
// checkRequestSize will throw IOException if request is rejected
zks.checkRequestSizeWhenReceivingMessage(len);
bb = ByteBuffer.allocate(len);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,6 @@ public void channelActive(ChannelHandlerContext ctx) throws Exception {
NettyServerCnxn cnxn = new NettyServerCnxn(channel, zkServer, NettyServerCnxnFactory.this);
ctx.channel().attr(CONNECTION_ATTRIBUTE).set(cnxn);

// Check the zkServer assigned to the cnxn is still running,
// close it before starting the heavy TLS handshake
if (!cnxn.isZKServerRunning()) {
LOG.warn("Zookeeper server is not running, close the connection before starting the TLS handshake");
ServerMetrics.getMetrics().CNXN_CLOSED_WITHOUT_ZK_SERVER_RUNNING.add(1);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am re-reading the patch again.
It looks like we are no more updating this metric.
and also we are dropping this case.

My understanding is that this check is here to prevent a flood of useless (but heavyweight) TLS handshakes after restarting the ZK node.

I am not sure this is a good move to remove this.
This fix may work on a small cluster (with very few ZK clients I mean)

@lvfangmin If I read correctly (from git blame) this improvement was part of ZOOKEEPER-3682 and the set of patches ported from Facebook ZooKeeper fork.

channel.close();
return;
}

if (handshakeThrottlingEnabled) {
// Favor to check and throttling even in dual mode which
// accepts both secure and insecure connections, since
Expand Down Expand Up @@ -264,9 +255,18 @@ public void channelActive(ChannelHandlerContext ctx) throws Exception {
if (remoteAddress != null
&& !((InetSocketAddress) remoteAddress).getAddress().isLoopbackAddress()) {
LOG.trace("NettyChannelHandler channelActive: remote={} local={}", remoteAddress, cnxn.getChannel().localAddress());
zkServer.serverStats().incrementNonMTLSRemoteConnCount();

if (zkServer == null || zkServer.serverStats() == null) {
LOG.warn("zkServer is not initialized " + (zkServer == null ? "" : "for stats ") + " no remote connection stats update done");
} else {
zkServer.serverStats().incrementNonMTLSRemoteConnCount();
}
} else {
zkServer.serverStats().incrementNonMTLSLocalConnCount();
if (zkServer == null || zkServer.serverStats() == null) {
LOG.warn("zkServer is not initialized " + (zkServer == null ? "" : "for stats ") + " no local connection count stats update done" );
} else {
zkServer.serverStats().incrementNonMTLSLocalConnCount();
}
}
}
}
Expand Down