Netflix/curator — Issue #29: InterProcessMutex leaves empty node
Author: ph1lm
Created: 2012-02-14 15:35:39+00:00
State: open

Below is groovy code I used for testing:

CuratorFramework framework = CuratorFrameworkFactory.builder().
connectString(System.getProperty('zookeeper.ensemble', config?.zookeeper?.ensemble ?: 'localhost:2281')).
sessionTimeoutMs(config?.zookeeper?.session?.timeout ?: 2 * 5000).
connectionTimeoutMs(config?.zookeeper?.connect?.timeout ?: 2 * 5000).
retryPolicy(new RetryNTimes(0, 0)).
build();
framework.start();

def getInteger(property, defaultValue) {
System.getProperty(property, "${defaultValue}") as Integer
}

getInteger('zookeeper.lock.quantity', 1).times {
def mutex = new InterProcessMutex(framework, '/some/test');
mutex.acquire()
try {
Thread.sleep(getInteger('zookeeper.lock.sleep', 0))
} finally {
mutex.release()
}
}

framework.close()

After execution I just connect to ZK using Cli:

[zk: localhost:2281(CONNECTED) 7] ls2 /some/test
[]
cZxid = 0x100000004
ctime = Tue Feb 14 17:20:05 EET 2012
mZxid = 0x100000004
mtime = Tue Feb 14 17:20:05 EET 2012
pZxid = 0x100000006
cversion = 2
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 0
numChildren = 0

Node /some/node still exists even after session disconnect.
That may cause a problem because if we don't clear child nodes - parent node may exceed size limit.

Jars used:
curator-client-1.1.0.jar
curator-framework-1.1.0.jar
curator-recipes-1.1.0.jar