curator-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Mikhailov (JIRA)" <>
Subject [jira] [Created] (CURATOR-43) Acquire gets stuck in InterProcessMutex if there are sub-nodes in lock path
Date Wed, 26 Jun 2013 15:34:19 GMT
Phil Mikhailov created CURATOR-43:

             Summary: Acquire gets stuck in InterProcessMutex if there are sub-nodes in lock
                 Key: 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:

public void testWithSubNode() throws Exception {
    final CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(),
new RetryOneTime(1));
    try {
        final InterProcessMutex lock = new InterProcessMutex(client, LOCK_PATH);
        final InterProcessMutex lock0 = new InterProcessMutex(client, LOCK_PATH + "/0");
        boolean acquired0 = lock0.acquire(5, TimeUnit.SECONDS);
        boolean acquired = lock.acquire(5, TimeUnit.SECONDS);
    } finally {

I also patched our curator build in LockInternals with this temporary patch before you found
better solution.

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>()
                public boolean apply(String s)
                    return s.startsWith(PROTECTED_PREFIX);
    return getSortedChildren(lockName, sorter, children);

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:

View raw message