apache / apache/curator

[CURATOR-212] checkState will set a new connection to old connected state

Open
#733 1 comment 0 reactions 0 assignees View on GitHub
bug imported-jira-issue
Dominant language
Java
Stars
3.2k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

consider the situation, after the EnsembleProvider changed the connection string, ConnectionState.process received a session event, which will invoke checkState to check whether the client is connected.



    @Override

public void process(WatchedEvent event)
{
//...
boolean wasConnected = isConnected.get();
boolean newIsConnected = wasConnected;
if ( event.getType() == Watcher.Event.EventType.None )
{
newIsConnected = checkState(event.getState(), wasConnected);
}

if ( newIsConnected != wasConnected )
{
isConnected.set(newIsConnected);
connectionStartMs = System.currentTimeMillis();
}
}



if the old connection state is SyncConnected or ConnectedReadOnly, isConnected will be set true, even the handleNewConnectionString() was invoked, and the state was reset to create a new connection.

After checkState return, process will set the new connection to the old connected state.



if ( checkNewConnectionString && zooKeeper.hasNewConnectionString() )

{
isConnected = false; // force to set it
handleNewConnectionString();
}


We could force the state to disconnected when we found a new connection will be create.

---
Originally reported by flier.lu, imported from: checkState will set a new connection to old connected state


  • status: Open
  • priority: Minor
  • resolution: Unresolved
  • imported: 2025-01-21

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.