Updated Branches: refs/heads/CURATOR-72 f0fc51f76 -> c40afd96a
if doSyncForSuspendedConnection repeatedly fails there may be an infinite loop of connection resets. So, after the first reset (signaled by getInstanceIndex value changing) give up and mark the connection LOST Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/c40afd96 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/c40afd96 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/c40afd96 Branch: refs/heads/CURATOR-72 Commit: c40afd96a0121ac45b340679174320f7b4f02d26 Parents: f0fc51f Author: randgalt <[email protected]> Authored: Mon Feb 3 13:46:28 2014 -0500 Committer: randgalt <[email protected]> Committed: Mon Feb 3 13:46:28 2014 -0500 ---------------------------------------------------------------------- .../org/apache/curator/framework/imps/CuratorFrameworkImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/c40afd96/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java index 3a2a48f..b480d9b 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java @@ -624,14 +624,15 @@ public class CuratorFrameworkImpl implements CuratorFramework // if instanceIndex != newInstanceIndex, the ZooKeeper instance was reset/reallocated // so the pending background sync is no longer valid long newInstanceIndex = client.getInstanceIndex(); - if ( instanceIndex == newInstanceIndex ) + if ( (instanceIndex < 0) || (instanceIndex == newInstanceIndex) ) { connectionStateManager.addStateChange(ConnectionState.LOST); } else { log.debug("suspendConnection() failure ignored as the ZooKeeper instance was reset. Retrying."); - doSyncForSuspendedConnection(newInstanceIndex); + // send -1 to signal that if it happens again, punt and mark the connection lost + doSyncForSuspendedConnection(-1); } } };
