curator-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jordan Zimmerman (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (CURATOR-43) Acquire gets stuck in InterProcessMutex if there are sub-nodes in lock path
Date Fri, 19 Jul 2013 18:16:50 GMT

     [ https://issues.apache.org/jira/browse/CURATOR-43?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Jordan Zimmerman closed CURATOR-43.
-----------------------------------

    Resolution: Not A Problem

This cannot be supported. Each Curator recipe would have to filter the nodes it gets from
getChildren. This would hurt performance and complicate the code. Further, it's unnecessary.


I'll add a Tech Note on the wiki about this. Curator must "own" any paths that it's given.
                
> 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

Mime
View raw message