curator-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sean-Michael Lewis (JIRA)" <>
Subject [jira] [Commented] (CURATOR-50) CreateBuilderImpl fails on forPath if connectString features a chroot that does not already exist.
Date Tue, 20 Aug 2013 17:58:54 GMT


Sean-Michael Lewis commented on CURATOR-50:

With a raw Zookeeper handle, you'd just create "/" or ensure that it exists before creating
its descendants. If your connect string has a chroot, creating "/" will create the chroot.
I've only verified this for a chroot of depth 1, however. Now that I think about it, I'm not
sure that that will work for deeper chroots.

I will test with EnsurePath, but its use of ZkPaths.makePath suggests that it will not try
to create "/". I can explicitly create "/" with CreateBuilderImpl if no namespace is set on
my framework. Regardless of namespace presence, other creates with createParentsIfNeeded will
not succeed unless "/" has been created manually.

I think there is an argument that if you configure with a chroot, it's on you to make sure
it's there. But the fact that you can create all of your ancestors in every other situation
suggests that ensuring the presence of "/" might not be so bad by default. Of course, if chroots
of depth > 1 make can't be handled by simply creating "/", then I'd agree that leaving
this to the user is preferable.

I'll do some more testing and report back.
> CreateBuilderImpl fails on forPath if connectString features a chroot that does not already
> --------------------------------------------------------------------------------------------------
>                 Key: CURATOR-50
>                 URL:
>             Project: Apache Curator
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 2.1.0-incubating
>            Reporter: Sean-Michael Lewis
>            Priority: Minor
> When a CuratorFramework is initialized with a connectString featuring a chroot that does
not already exist in the ensemble, CreateBuilderImpl will fail to create new nodes even if
createParentsIfNeeded is true.
> For example, the following code will result in a org.apache.zookeeper.KeeperException$NoNodeException.
> {code}
> CuratorFramework client = CuratorFramework.builder().retryPolicy(myPolicy).connectString("myServer1:2181,myServer2:2181/chroot).build();
> client.create().createParentsIfNeeded().forPath("test");
> {code}
> This can be worked around by using a namespace in lieu of the chroot or by calling {code}client.create().forPath("/"){code}
before attempting to create any other nodes. 
> While using namespaces is likely the best practice, the framework does initialize with
the chroot connectString. There are also reasons why one might want to use both chroot connectStrings
as well as namespaces (application environments for the former, application for the latter).
> My proposed fix is to alter {code}ZkPaths.mkdirs{code} to not skip "/" when it walks
the tree. In cases where no chroot configured or a chroot that already exists, the node will
be found and skipped. Otherwise, it will be created.

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