Description

Multiple Contrail components running as Zookeeper clients are assigned a session ID.

This article provides a simple explanation of how the session ID is formatted. Understanding the formatting will help you during troubleshooting to identify which is the original zookeeper server that a client connects to, and whether the client is reconnected to zookeeper ensemble. 

Solution

The session ID consists of a 1-byte long server ID which represents the zookeeper server ID (myid) in the ensemble, a 5-byte long truncated timestamp that represents the creation time of this session, and a 2-byte long reserved field which is used for re-connection. 

Field      server id    timestamp    reserved for re-connection
Length     8            40           16

Use '/usr/share/zookeeper/bin/zkCli.sh' command to enter zookeeper CLI. For the following znode, it is created by session ID 0x26d9d24aec60008 . This session ID can be broken into 3 parts:

  1. server id 0x2
  2. truncated timestamp 0x6d9d24aec6
  3. reserved field 0x0008

From this information, we know this client was initially connected to zookeeper server with ID value 2. 

# /usr/share/zookeeper/bin/zkCli.sh
Connecting to localhost:2181
<snipped>
[zk: localhost:2181(CONNECTED) 4] get /svc-monitor/ead8d60a310c448ab530809bc15bc354__lock__0000000559
22166
cZxid = 0x6c000001c9
ctime = Sat Oct 05 11:27:33 PDT 2019
mZxid = 0x6c000001c9
mtime = Sat Oct 05 11:27:33 PDT 2019
pZxid = 0x6c000001c9
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x26d9d24aec60008
dataLength = 5
numChildren = 0

When checking session ID, if the zookeeper server that is currently connected has a different server ID parsed from the session ID, or the reserved field has increased value, this indicates the client has had some connection issue before. 

For more on troubleshooting Zookeeper, refer to KB31144 - Contrail Getting Started - Administration, Configuration & Troubleshooting (JumpStation) [juniper.net]

Related Information