Accumulo
  1. Accumulo
  2. ACCUMULO-965

Zookeeper session ids created as unsigned long, parsed in ZooUtils.java as signed long

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.4.2
    • Fix Version/s: 1.4.3, 1.5.0
    • Component/s: start
    • Labels:
      None
    • Environment:

      Hadoop 0.20, ZooKeeper 3.4.3, CentOS 2.6, x64 CPU, Java 1.6.0_24

      Description

      Seems like this may be a bug. I looked at
      LiveTServerSet.assignTablet() it eventually calls Long.toHexString().
      The javadoc for toHexString() says the following.

      Returns a string representation of the <code>long</code>
      argument as an unsigned integer in base 16.
      

      However, the method we are using to parse the Long can not handle
      unsigned longs greater than MAX_LONG. There does not seem to be a
      method in long that can parse the output of toHexString(). For
      example the following will fail, any negative number will fail.

      Long.parseLong(Long.toHexString(-1), 16);

      Original Stack Dump:

      java.lang.NumberFormatException: For input string: "b53c3a3610ce0001"
      	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
      	at java.lang.Long.parseLong(Long.java:422)
      	at org.apache.accumulo.core.zookeeper.ZooUtil$LockID.<init>(ZooUtil.java:64)
      	at org.apache.accumulo.server.tabletserver.TabletServer$ThriftClientHandler.checkPermission(TabletServer.java:1794)
      	at org.apache.accumulo.server.tabletserver.TabletServer$ThriftClientHandler.loadTablet(TabletServer.java:1814)
      	at org.apache.accumulo.core.tabletserver.thrift.TabletClientService$Processor.process(TabletClientService.java:2037)
      	at org.apache.accumulo.server.util.TServerUtils$TimedProcessor.process(TServerUtils.java:154)
      	at org.apache.thrift.server.TNonblockingServer$FrameBuffer.invoke(TNonblockingServer.java:631)
      	at org.apache.accumulo.server.util.TServerUtils$THsHaServer$Invocation.run(TServerUtils.java:202)
      

        Activity

        Hide
        Eric Newton added a comment -

        It's traditional to use an arbitrarily assigned, but small number for each zookeeper node. Like "1" or "2" or "3".

        Show
        Eric Newton added a comment - It's traditional to use an arbitrarily assigned, but small number for each zookeeper node. Like "1" or "2" or "3".
        Hide
        Rich Alberth added a comment -

        > The bits "b5" come from the myid file. Can you verify that your myid file contains a small number?

        Confirmed! Namenode is 180, data nodes are 181 and 182. 0xb5=181 base 10. Works out right.

        Show
        Rich Alberth added a comment - > The bits "b5" come from the myid file. Can you verify that your myid file contains a small number? Confirmed! Namenode is 180, data nodes are 181 and 182. 0xb5=181 base 10. Works out right.
        Hide
        Hudson added a comment -

        Integrated in Accumulo-1.4.x #267 (See https://builds.apache.org/job/Accumulo-1.4.x/267/)
        ACCUMULO-965 merge to 1.4 (Revision 1433481)

        Result = SUCCESS
        ecn :
        Files :

        • /accumulo/branches/1.4
        • /accumulo/branches/1.4/src
        • /accumulo/branches/1.4/src/core
        • /accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/zookeeper/ZooUtil.java
        • /accumulo/branches/1.4/src/server
        • /accumulo/branches/1.4/src/server/src
        Show
        Hudson added a comment - Integrated in Accumulo-1.4.x #267 (See https://builds.apache.org/job/Accumulo-1.4.x/267/ ) ACCUMULO-965 merge to 1.4 (Revision 1433481) Result = SUCCESS ecn : Files : /accumulo/branches/1.4 /accumulo/branches/1.4/src /accumulo/branches/1.4/src/core /accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/zookeeper/ZooUtil.java /accumulo/branches/1.4/src/server /accumulo/branches/1.4/src/server/src
        Hide
        Eric Newton added a comment -

        The bits 0x3c3a3610ce in your session id correspond to the time of 0x13c3a3610ce, which is 01/14/2013 at 1PM EST.

        The bits "b5" come from the myid file. Can you verify that your myid file contains a small number?

        Show
        Eric Newton added a comment - The bits 0x3c3a3610ce in your session id correspond to the time of 0x13c3a3610ce, which is 01/14/2013 at 1PM EST. The bits "b5" come from the myid file. Can you verify that your myid file contains a small number?
        Hide
        Eric Newton added a comment -

        Digging into the zookeeper code, it looks like session ids consist of 8 bits of myid, time shifted 16 bits left.

        The problem is that time is now 41 bits... and they shift those bits left 24, then right 8. The shift right is an arithmetic shift, so sign extension is possible. The myid bits are or'd into the upper most bits, so if sign extension happens, they will all be set to 1's. The current time, in hex, looks like this:

        0x13c3f143771

        It would be very strange to have a time value where the upper bit of the second hex digit would be set. That will be 0x18000000000 (April, 2022), or 0xffffffffff (November, 2004)

        Or, we could be using a myid up in the range of 0x80. If someone was to put the zookeeper port number (2181, or 0x885) into the myid file, that might cause this problem.

        Show
        Eric Newton added a comment - Digging into the zookeeper code, it looks like session ids consist of 8 bits of myid, time shifted 16 bits left. The problem is that time is now 41 bits... and they shift those bits left 24, then right 8. The shift right is an arithmetic shift, so sign extension is possible. The myid bits are or'd into the upper most bits, so if sign extension happens, they will all be set to 1's. The current time, in hex, looks like this: 0x13c3f143771 It would be very strange to have a time value where the upper bit of the second hex digit would be set. That will be 0x18000000000 (April, 2022), or 0xffffffffff (November, 2004) Or, we could be using a myid up in the range of 0x80. If someone was to put the zookeeper port number (2181, or 0x885) into the myid file, that might cause this problem.
        Hide
        Hudson added a comment -

        Integrated in Accumulo-Trunk #638 (See https://builds.apache.org/job/Accumulo-Trunk/638/)
        ACCUMULO-965 handle negative zookeeper session ids (Revision 1433477)

        Result = SUCCESS
        ecn :
        Files :

        • /accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooUtil.java
        Show
        Hudson added a comment - Integrated in Accumulo-Trunk #638 (See https://builds.apache.org/job/Accumulo-Trunk/638/ ) ACCUMULO-965 handle negative zookeeper session ids (Revision 1433477) Result = SUCCESS ecn : Files : /accumulo/trunk/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooUtil.java
        Hide
        Eric Newton added a comment -

        I'm still a little worried that we've never seen a negative session id before, but if we do, the code will handle it.

        Show
        Eric Newton added a comment - I'm still a little worried that we've never seen a negative session id before, but if we do, the code will handle it.

          People

          • Assignee:
            Eric Newton
            Reporter:
            Rich Alberth
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development