cancel
Showing results for 
Search instead for 
Did you mean: 

ConcurrencyFailureException: Failed to update node

spilby
Confirmed Champ
Confirmed Champ
I'm using Alfresco Enterprise v4.1.6

I create a new node and then modify some properties of the parents doing a getNodeService().addProperties.

Sometimes, this addProperties fails and give me a org.springframework.dao.ConcurrencyFailureException: Failed to update node 288941

And when it occurs, I can't see the node that I create and can't doing anything on this node. Only works again if I restart Alfresco tomcat server.

I supose that this ocurrs because various users create nodes with same parents and modify the properties at a same time.  

What can I do to solve this? How do you modify properties or nodes for avoid this exception?

Thank you!
21 REPLIES 21

mrogers
Star Contributor
Star Contributor
This is an expected exception that is handled automatically (by retry) in Alfresco's RetryingTransactionHandler.

You can't see the node because its not been created!

Please correct your transaction handling or post your code so others may point out the error.

spilby
Confirmed Champ
Confirmed Champ
Oks, this is a resume of my code:

First I create the folders with my own properties. I create various nodes calling this code:
<blockquote>
   NodeRef nodeRef = getNodeService().createNode(parent, ContentModel.ASSOC_CONTAINS,
                           QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name),
                           QName.createQName(Constants.myModel, Constants.myDocumentType),
                           properties).getChildRef(); 
</blockquote>

When I finish, I update a document.
<blockquote>
   writer = getContentService().getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
   writer.putContent(inputStream);
</blockquote>

And then, I modify various properties, from the child node to the root calling recursively a method.
<blockquote>
   private void modifyProperties(NodeRef nodeRef) {

      Map<QName, Serializable> updateableProperties = changeProperties(…);

      getNodeService().addProperties(nodeRef, updateableProperties);
      NodeRef parent = getNodeService().getPrimaryParent(nodeRef).getParentRef();
      if (!isRoot) {
         modifyProperties(parent);
      }
   }
</blockquote>

I log all of this, and the createNode and putContent seems goes ok, because the createNode gives me a nodeRef. I log this nodeRef with a getPath and gives me a path with the new folder.

The "ConcurrencyFailureException: Failed to update node" is thrown when I do the getNodeService().addProperties. In this point, the exceptions appears. But appears sometimes. Doing the same, I delete the folders and test the same, and sometimes do all ok, and other times gives me the exception.

You can see something wrong? I don't know where is the error. Need more information?

Thanks again!


mrogers
Star Contributor
Star Contributor
That code is O.K.  In particular there is no incorrect catching of exceptions.

But how is it running? 

For example if its a webscript or action then the transaction is already started for you.

—-

While that algorithm should be O.K. for small volumes you are going to cause contention on your parent nodes.   May be worth re-considering your requirements and implementation for larger volumes.

spilby
Confirmed Champ
Confirmed Champ
It's a java backed webscript. Arrives an XML to another platform, a petition to create a number of paths, with a name, some properties and a path where I can find a archive. Then, this platform call by REST to my java backed webscript, who do the work to create these nodes and upload the archive.

The last point that recommends me, where is the problem for larger volumes? I'm sorry, I work with this API since a few weeks ago and don't know how it can be better for large volumes.

Thanks mrogers.

spilby
Confirmed Champ
Confirmed Champ
I have more information about this error…

In resume, my java webscript do this:

1. Create various nodes: A, B, C, D, making a path A/B/C/D
2. Put a content in the node D.
3. addProperties on A, B, C nodes.

I run the webscript, and do all ok.

The ConcurrencyFailureException occurs exactly when:

I go to the Alfresco Repository Navigator and delete manually the folder B.

Then, I run another time my webscript. Create the nodes ok, put the content ok, begin to modify the properties ok, but when try to modify the properties of the node A, throw this exception. And I can't do anything until I restart the alfresco server. When I delete the folder with the navigator, seems to blocks the A node and I can't modify these properties.

Does it make sense? Where is the problem?

Please, if someone have a information about this… it's important to resolve. Thanks again.

spilby
Confirmed Champ
Confirmed Champ
The problem continues… I don't know what can I do to resolve it. Anyone have a similar problem? How do you update your properties protecting your node for the concurrency exception? Deleting a folder with the alfresco explorer may cause problems? Some information could help me, thanks.

romschn
Star Collaborator
Star Collaborator
Can you give a try using LockService on a node to check if the node is locked or not. If a node is locked then don't do anything. Only proceed when a node is not locked. See if this help you solve your problem or not. Take a look at getIsLocked() method in ScriptNode class for how to implement this.

Hope this helps.

spilby
Confirmed Champ
Confirmed Champ
Thanks Ramesh, but don't works. I put the getItsLocked and returns me that the node isn't locked. But when I try to change the properties, throws the concurrency exception.

There are something in the Alfresco Explorer that when delete a son folder of a node, the properties of that node can't be changed. The node isn't blocked because I can create a new node and put like a child of this node. And if I don't change the properties all goes ok. The problem is only with the properties.

More ideas? I don't have anything more Smiley Surprised(

mrogers
Star Contributor
Star Contributor
IIRC There's a check in the node service that you cant add a child to a deleted node (Otherwise you can get into infinite loops when using policies)

There's also probably a check to stop you updating a deleted node since that makes no sense.

I suspect there's something else going on in your code that you have not mentioned.