You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@curator.apache.org by "Phil Mikhailov (JIRA)" <ji...@apache.org> on 2013/06/26 17:34:19 UTC
[jira] [Created] (CURATOR-43) Acquire gets stuck in
InterProcessMutex if there are sub-nodes in lock path
Phil Mikhailov created CURATOR-43:
-------------------------------------
Summary: Acquire gets stuck in InterProcessMutex if there are sub-nodes in lock path
Key: CURATOR-43
URL: https://issues.apache.org/jira/browse/CURATOR-43
Project: Apache Curator
Issue Type: Bug
Components: Recipes
Affects Versions: 2.0.1-incubating
Reporter: Phil Mikhailov
If lock path has sub-node, this sub-node is also treated as try to acquire this lock.
I created small test method in TestInterProcessMutex that reproduces this issue:
{noformat}
@Test
public void testWithSubNode() throws Exception {
final CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
try {
client.start();
final InterProcessMutex lock = new InterProcessMutex(client, LOCK_PATH);
final InterProcessMutex lock0 = new InterProcessMutex(client, LOCK_PATH + "/0");
boolean acquired0 = lock0.acquire(5, TimeUnit.SECONDS);
Assert.assertTrue(acquired0);
lock0.release();
boolean acquired = lock.acquire(5, TimeUnit.SECONDS);
Assert.assertTrue(acquired);
lock.release();
} finally {
client.close();
}
}
{noformat}
I also patched our curator build in LockInternals with this temporary patch before you found better solution.
{noformat}
static final String PROTECTED_PREFIX = "_c_";
public static List<String> getSortedChildren(CuratorFramework client, String basePath, final String lockName, final LockInternalsSorter sorter) throws Exception
{
List<String> children = Lists.newArrayList(Collections2.filter(client.getChildren().forPath(basePath),
new Predicate<String>()
{
@Override
public boolean apply(String s)
{
return s.startsWith(PROTECTED_PREFIX);
}
}));
return getSortedChildren(lockName, sorter, children);
}
{noformat}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira