You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@curator.apache.org by "Jordan Zimmerman (JIRA)" <ji...@apache.org> on 2013/07/20 17:02:50 UTC
[jira] [Commented] (CURATOR-43) Acquire gets stuck in
InterProcessMutex if there are sub-nodes in lock path
[ https://issues.apache.org/jira/browse/CURATOR-43?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13714447#comment-13714447 ]
Jordan Zimmerman commented on CURATOR-43:
-----------------------------------------
https://cwiki.apache.org/confluence/display/CURATOR/TN7
> 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
> Assignee: Jay Zarfoss
>
> 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:
> @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();
> }
> }
> 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>()
> {
> @Override
> 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: http://www.atlassian.com/software/jira