This is an automated email from the ASF dual-hosted git repository.
arshad pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zookeeper.git
The following commit(s) were added to refs/heads/master by this push:
new ea75e1f ZOOKEEPER-4247: NPE while processing message from restarted
quorum member
ea75e1f is described below
commit ea75e1f63572fc72fb8520ba8c793523047acb49
Author: Mate Szalay-Beko <[email protected]>
AuthorDate: Wed Apr 14 22:22:09 2021 +0530
ZOOKEEPER-4247: NPE while processing message from restarted quorum member
When a ZooKeeper server realizes that an other quorum peer was shut down
(e.g. during a rolling upgrade or
rolling restart), the ServerCnxn.zkServer variable is set to null by
QuorumPear.close(). This is why in the code
we usually check the zkServer variable before using it. But this check was
missing in one place thus causing
NPE in NettyServerCnx.receiveMessage:
```
2021-02-08T12:42:08.229+0000 [myid:] - ERROR
[nioEventLoopGroup-4-1:NettyServerCnxnFactory$CnxnChannelHandler329]-
Unexpected exception in receive
java.lang.NullPointerException: null ~[zookeeper-3.6.2.jar:3.6.2]
at
org.apache.zookeeper.server.NettyServerCnxn.receiveMessage(NettyServerCnxn.java:518)
at
org.apache.zookeeper.server.NettyServerCnxn.processMessage(NettyServerCnxn.java:368)
at org.apache.zookeeper.server.NettyServerCnxnFactory
$CnxnChannelHandler.channelRead(NettyServerCnxnFactory.java:326)
...
```
In this commit we add the necessary check and (after throwing an
IOException) we will basically ignore the
processing of the received message when the remote ZooKeeper server is
already down.
Author: Mate Szalay-Beko <[email protected]>
Reviewers: Enrico Olivelli <[email protected]>, Mohammad Arshad
<[email protected]>
Closes #1681 from symat/ZOOKEEPER-4247 and squashes the following commits:
7b140177d [Mate Szalay-Beko] ZOOKEEPER-4247: address PR comments
b99ee986b [Mate Szalay-Beko] ZOOKEEPER-4247: address PR comments
3c8478a40 [Mate Szalay-Beko] ZOOKEEPER-4247: fix NPE happens while
processing messages during quorum member restart
---
.../src/main/java/org/apache/zookeeper/server/NettyServerCnxn.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git
a/zookeeper-server/src/main/java/org/apache/zookeeper/server/NettyServerCnxn.java
b/zookeeper-server/src/main/java/org/apache/zookeeper/server/NettyServerCnxn.java
index 110807a..269fcd9 100644
---
a/zookeeper-server/src/main/java/org/apache/zookeeper/server/NettyServerCnxn.java
+++
b/zookeeper-server/src/main/java/org/apache/zookeeper/server/NettyServerCnxn.java
@@ -520,8 +520,12 @@ public class NettyServerCnxn extends ServerCnxn {
if (len < 0 || len > BinaryInputArchive.maxBuffer) {
throw new IOException("Len error " + len);
}
+ ZooKeeperServer zks = this.zkServer;
+ if (zks == null || !zks.isRunning()) {
+ throw new IOException("ZK down");
+ }
// checkRequestSize will throw IOException if request
is rejected
- zkServer.checkRequestSizeWhenReceivingMessage(len);
+ zks.checkRequestSizeWhenReceivingMessage(len);
bb = ByteBuffer.allocate(len);
}
}