Paul Millar created ZOOKEEPER-2812:
--------------------------------------

             Summary: Racy implicit SessionTracker creation
                 Key: ZOOKEEPER-2812
                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2812
             Project: ZooKeeper
          Issue Type: Bug
          Components: server
    Affects Versions: 3.4.8
            Reporter: Paul Millar
            Priority: Minor


As with ZOOKEEPER-2810, NIOServerCnxnFactory#startup current starts the 
acceptor thread before initialising the ZooKeeperServer object.  This leads to 
a race-condition between any incoming connection and the thread initialising 
the ZooKeeperServer.

If the incoming connection wins the race then the thread processing this 
connection will see an uninitialised SessionTracker object, resulting in the 
following NPE being thrown:

{noformat}
java.lang.NullPointerException: null
        at 
org.apache.zookeeper.server.ZooKeeperServer.createSession(ZooKeeperServer.java:569)
 ~[zookeeper-3.4.8.jar:3.4.8--1]
        at 
org.apache.zookeeper.server.ZooKeeperServer.processConnectRequest(ZooKeeperServer.java:902)
 ~[zookeeper-3.4.8.jar:3.4.8--1]
        at 
org.apache.zookeeper.server.NIOServerCnxn.readConnectRequest(NIOServerCnxn.java:418)
 ~[zookeeper-3.4.8.jar:3.4.8--1]
        at 
org.apache.zookeeper.server.NIOServerCnxn.readPayload(NIOServerCnxn.java:198) 
~[zookeeper-3.4.8.jar:3.4.8--1]
        at 
org.apache.zookeeper.server.NIOServerCnxn.doIO(NIOServerCnxn.java:244) 
~[zookeeper-3.4.8.jar:3.4.8--1]
        at 
org.apache.zookeeper.server.NIOServerCnxnFactory.run(NIOServerCnxnFactory.java:203)
 ~[zookeeper-3.4.8.jar:3.4.8--1]
{noformat}

Again, as with ZOOKEEPER-2810, the naive fix (starting the acceptor thread last 
in NIOServerCnxnFactory#startup method) may fix this issue.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to