Apache Curator connection state listener not always called with RECONNECTED state change

1.1k Views Asked by At

I am using Apache Curator v4.3.0 (ZK v3.5.8), and I noticed that in some disconnect/reconnect scenarios, I stop getting a RECONNECTED event to the registered listener/s.

CuratorFramework client = ...; 
   // retry policy is RetryUntilElapsed with Integer.MAX_VALUE
   // sessionTimeout is 15 sec
   // connectionTimeout is 5 sec

client.getConnectionStateListenable().addListener(new ConnectionStateListener()...

Although I do see that the ConnectionStateManager prints the state change:

[org.apache.zookeeper.ClientCnxn] - Client session timed out, have not heard from server in 15013ms for sessionid 0x10000037e340012, closing socket connection and attempting reconnect
[org.apache.zookeeper.ClientCnxn] - Opening socket connection to server 
...
[org.apache.curator.ConnectionState] - Session expired event received
[org.apache.zookeeper.ClientCnxn] - Session establishment complete on server
[org.apache.curator.framework.state.ConnectionStateManager] - State change: RECONNECTED

Usually right after I see my listener called on stateChanged, but not always.

The CuratorFramework client is shared between multiple components registering different listeners. I didn't see any restriction to have only one client per listener. But, when I don't share it, the problem doesn't occur anymore.

Any suggestions on how to proceed debugging this problem?

Thank you, Meron

1

There are 1 best solutions below

3
On

This appears to be the bug that was fixed in Curator 5.0.0 - https://issues.apache.org/jira/browse/CURATOR-525 - if you can please test with 5.0.0 and see if it fixes the issue.