ConcurrencyFailureException: Failed to update node

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2014 04:25 AM
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!
- Labels:
-
Archive

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2014 06:38 AM
Maybe is complicate to explain… In resume:
- Run webscript. It creates a folder A, a folder B, a folder C, puts a content in C and update properties of C, B and A. (THIS WORKS) Path obtained: A / B / C
- Go to Alfresco Explorer and delete the node B.
- Run webscript. It creates a folder B (child of A), create a folder C, put a content in C, update the properties of C, B and when try to update the properties of A, throw the concurrency exception. Path obtained: A
If I change my code and don't change properties, only create nodes and put content, all works. Only the getNodeService().addProperties gives the problem.
I try to wait 1 minute before update the properties, but the same error. The properties are blocked forever if I delete the node with Alfresco Explorer. Only if i restart the server I can update the properties again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2014 06:17 AM
UserTransaction trx_A = transactionService.getNonPropagatingUserTransaction();try{trx_A.begin();//Folder Creation logictrx_A.commit();} catch(Throwable e) { try { trx_A.rollback(); } catch (Throwable ee) { }}//Create another transaction and do same as above and add properties add logic if folder creation was success
Also, for deletion part, i am assuming you want to delete child folder and update parent folder's property. For this scenario as well separate the logic in two different transaction as mentioned above.
See implementing this way works for you or not.
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2014 06:47 AM
Is possible that the explorer have a problem that blocks the modification of the properties of a node, if I delete one of his sons, until the restarting of the server?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2014 06:56 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2014 07:41 AM
I attach a image.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2014 08:03 AM
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2014 08:49 AM

Two questions about this. Is a good practice use always transactions? In the examples that I read on tutorials or forums, don't use usually transactions. Maybe in my case, that do different actions in the same webscript, like create nodes or update properties, is the most correct?
And the other… Why getNonPropagatingUserTransaction and not getUserTransaction? What's the difference?
Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2014 02:28 AM
Generally, it is not suggested to explicitly handle the transactions in the custom code. However, to my opinion, if required we can use the explicit transactions to meet the requirement and good thing is that Transaction Service provides the required APIs to do that so we can leverage on it. In your scenario it appears that it was something related to transaction which was causing the exception. Hence, handling the transactions explicitly we made sure that we have the processed node for adding properties hence it should not cause any exceptions on it while adding the properties.
The reason for using non-propagating transaction is - it uses the propagation as REQUIRES_NEW. Hence, each time a new transaction will be created wherein user transaction use the propagation as REQUIRES which means that if the transaction is already running it will take that or else will create a new transaction. So, in order to make sure that each time a new transaction is used non-propagating transaction was mentioned.
Hope this answers your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2014 03:29 AM
Is strange because if I don't put the UserTransaction in the code, each operation (createNode, putContent, addProperties, etc) is doing with her own transaction (if I understand it). Control the transaction only serves for doing 2 or more operations in a same transaction. But isn't my case. I do a transaction for each operation. But I need to put it to solve the concurrency exception.
One question more about the non-propagating… Oks, the non-propagating (REQUIRES_NEW) ensures that the transaction is new always. I supose that the problem using the getUserTransaction is that if the transaction is already running, and I use that, the concurrency problem may appears another time. But use always a new transaction, could give me problems of performance? A lot of users will use this service, and for each one the code will use 4 o 5 transactions (one for each operation). This could cause problems? In which times is better use the running transaction (getUserTransaction option)?
Thanks again!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2014 07:52 AM

But… now the addProperties give me a concurrency exception if before I EDIT the properties with the Alfresco Explorer and save. ¿?¿?¿?
In resume… I go to a folder with the Alfresco Explorer, edit the properties (right mouse button) and save. This node seems to be blocked, until I restart the server. I can't call to addProperties in my webscript because it returns me the concurrency exception.
I don't understand nothing, the delete problem has been resolved with the transactions, but modify properties seems to run different. What's the problem with the Alfresco Explorer? Why block the properties of the nodes?

