You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@curator.apache.org by "Chevaris (Jira)" <ji...@apache.org> on 2020/05/06 08:07:00 UTC

[jira] [Commented] (CURATOR-507) PERSISTENT NODE ISSUE

    [ https://issues.apache.org/jira/browse/CURATOR-507?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17100561#comment-17100561 ] 

Chevaris commented on CURATOR-507:
----------------------------------

I realized that I forgot to answer to this issue. I was not able to reproduce anymore. I guess it was an error on my application.

I am closing the issue.

 

> PERSISTENT NODE ISSUE
> ---------------------
>
>                 Key: CURATOR-507
>                 URL: https://issues.apache.org/jira/browse/CURATOR-507
>             Project: Apache Curator
>          Issue Type: Bug
>          Components: Recipes
>    Affects Versions: 4.1.0
>            Reporter: Chevaris
>            Priority: Major
>
> Hi there,
> I am using Apache Curator 4.1.0 with Zk 3.4.10 (Open JDK 1.8)
> openjdk version "1.8.0_191"
> I am PersistentNode recipe and I am receiving this exception
>  
> java.lang.IllegalStateException: initial create has not been processed. Call waitForInitialCreate() to ensure.
>  at org.apache.curator.shaded.com.google.common.base.Preconditions.checkState(Preconditions.java:444)
>  at org.apache.curator.framework.recipes.nodes.PersistentNode.setData(PersistentNode.java:392)
>  at com.cheva.udr.sm.RemoteReporter.reportToRemote(RemoteReporter.java:67)
>  at com.cheva.udr.sm.RemoteReporter.lambda$2(RemoteReporter.java:84)
>  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
>  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>  at java.lang.Thread.run(Thread.java:748)
>  
> My class RemoteReporter.java (assumes that PersistentNode is thread safe)
> // The class is final, and the attribute is private final so allow safe publication
> private final Persistent pn;
> Constrcutor() {
> ...
> PersistentNode pn = new PersistentNode(cf, CreateMode.EPHEMERAL, false, path, dataToReport());
> }
> // Class has also an start method
> start() {
> ...
> 79 pn.start();
> ...
> // Create new thread and execute the follwoing code
> 84 pn.waitForInitialCreate(1000, TimeUnit.DAYS);
> 85 pn.setData("XXx");
> 86 statusCache.getListenable().addListener(listener);
> }
> I was checking the PersistentNode code and the excepction happens because nodePath.get()==null variable. I am not 100% sure if the problem is in my code or in the recipe...
> - My code is using the waitForinitial as suggested
> - The recipe uses a CountDownLatch, but there are 2 different paths for the latch to be countDown (via initalisationComplete() method), and I am not sure that one of them assures that nodePath.get() != null
> In this code snippet, you can see that the latch is countDown, but I am not sure that nodePath.set(whatever) is called, so I guess there could be a race condition
> private final BackgroundCallback setDataCallback = new BackgroundCallback()
>  {
> @Override
>  public void processResult(CuratorFramework dummy, CuratorEvent event)
>  throws Exception
>  {
>  //If the result is ok then initialisation is complete (if we're still initialising)
>  //Don't retry on other errors as the only recoverable cases will be connection loss
>  //and the node not existing, both of which are already handled by other watches.
>  if ( event.getResultCode() == KeeperException.Code.OK.intValue() )
>  {
>  //Update is ok, mark initialisation as complete if required.
>  initialisationComplete();
>  }
>  else if ( event.getResultCode() == KeeperException.Code.NOAUTH.intValue() )
>  {
>  log.warn("Client does not have authorisation to write node at path {}", event.getPath());
>  authFailure.set(true);
>  }
>  }
>  };
> Thanks in adavance for the help,
> Evaristo
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)