curator-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cameron McKenzie (JIRA)" <>
Subject [jira] [Commented] (CURATOR-179) Sequential path creation of /somepath/N throws exception
Date Wed, 07 Jan 2015 02:23:34 GMT


Cameron McKenzie commented on CURATOR-179:

You're correct about where the issue was introduced. So, this forces you to have a prefix
for your sequential nodes.

The issue is that the ZKPaths.fixForNamespace() has no context as to whether the node being
created is sequential or not.

[~dragonsinth], I believe that you added this fix. Any suggestions? We could just remove the
validatePath() call from ZKPaths.fixForNamespace(), but it is arguably nice to have that validation
there. Changing the fixForNamespace() stuff to be aware of the fact that the node being created
is sequential is another option, but this will have a reasonably large impact as it's used
in quite a number of places.

> Sequential path creation of /somepath/N throws exception
> --------------------------------------------------------
>                 Key: CURATOR-179
>                 URL:
>             Project: Apache Curator
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 2.7.0
>            Reporter: Ryan Luecke
> A new error is thrown when attempting to run one of our scala services with Curator 2.7.0.
The error does not throw in 2.6.0 (or in 2.5.0, which is when the original code was written.
We were updating to 2.7.0).
> Stack trace:
> [error] Exception in thread "main" java.lang.IllegalArgumentException: Path must not
end with / character
> [error] 	at org.apache.curator.utils.PathUtils.validatePath(
> [error] 	at org.apache.curator.utils.ZKPaths.fixForNamespace(
> [error] 	at org.apache.curator.framework.imps.NamespaceImpl.fixForNamespace(
> [error] 	at org.apache.curator.framework.imps.CuratorFrameworkImpl.fixForNamespace(
> [error] 	at org.apache.curator.framework.imps.CreateBuilderImpl$1.forPath(
> [error] 	at org.apache.curator.framework.imps.CreateBuilderImpl$1.forPath(
> [error] 	at<application code>.scala:175)
> ...
> This happens when we try to create node /somepath/N (where N is sequential zk node).
> In Curator, PathUtils.validatePath has two signatures:
> 1. public static void validatePath(String path, boolean isSequential) throws IllegalArgumentException
>      validatePath(isSequential? path + "1": path);
>    }
> 2. public static String validatePath(String path) throws IllegalArgumentException {
>   ...
>   throws if path ends in '/'
>   ...
> }
> In our case, path /somepath/ does end in '/'
> The way #1 calls #2 appears to be a hack (appending "1" to path in order to validate).
This would have caused path validation to *succeed* for our case - however, the caller MUST
call this #1 signature of validatePath. The code calls actually calls #2 instead.
> 2.5.0 released May 28, 2014
> 2.6.0 released July 11, 2014
> * issue introduced
> 2.7.0 released November 3, 2014
> I believe the issue was introduced on July 29 2014, when a call to #2 above was added
to fixForNamespace(String namespace, String path) in
> We've decided to workaround the issue at the moment. Our workaround is straightforward:
> Change our sequential node path from /somepath/N
> to /somepath/entry_N
> Please get in touch if you need additional information to solve this issue. Thanks!

This message was sent by Atlassian JIRA

View raw message