AnsweredAssumed Answered

Issue with transactions

Question asked by ilopez88 on Feb 1, 2017



We are experiencing some issues with our Alfresco customization plugin, which I will now detail in hopes that somebody out here will shed some light on what may be the issue since we are unable to find it, I understand this is a bit too much, but if you could point in the right direction or what could be wrong I'd appreciate it.


When a document is CREATED on Alfresco:

-   Through the OnCreateNodePolicy we set some properties and add some aspects to the document based on the current site and location and parent folder properties, one of the properties to be set in the document is a number, (we use a defined node in alfresco as a  "counter" which has an aspect with a numeric property, with a retrying transaction it gets increased and the value retrieved).

-   Depending on the site of the node, it triggers an action (sync) which iterates over two specific folders on the same site, looking for a name match, and if found, it sets a property on the newly created document with the value of it's text rendition, (if it does not exists it triggers another action which creates said rendition), after that, it creates an association between the found document and the new one, this last part is wrapped in a retrying transaction.


When a document is UPDATED on Alfresco:

-   Through the OnUpdateNodePolicy, if the document is a pdf we use a PDDocument to retrieve the number of pages and set it on a property, after that we validate that the properties set on the "create" procedure are still correct(in case the document was moved or copied) and set them again if required, after that we trigger an async action to create renditions on the document(the action executeImpl uses a retrying transaction to do the process).


Besides of this, we have two webscripts,

-    The first one triggers a process to REPLICATE the selected document into another folder, it creates a node in the target folder, creates associations between the selected document and this replica, adds aspects and increases the numeric number stated above (because they are different documents), after that it replicates the content, and then it attempts to retrieve all the associations from the selected document and add them to the replicated document, then does the same with most of the properties (nodeService.getProperties), all this process wrapped in a retrying transaction.


-   The second webscript purpose is to REFRESH a replicated document, the idea(and the code) is the same as the previous one, with the difference that it does not create the node, because it is already provided, and that also updates the version of the replica based on parameters(minor or major version), all of this process wrapped in a retrying transaction like the previous.


The create and update policies work fine so far, also executing the replicate webscript works too.


When executing the first webscript there is no issue, the problem appears when trying to execute the refresh one, the retrying transaction gets rollled back without error or reason, when I enable the SpringAwareUserTransaction debug logs, then I can see that the reason is "Exception attempting to pass transaction boundaries", disabling the transaction on the webscript I got to know that a "nodeService.createAssociation" was the last piece of custom code being executed before throwing the exception.

Also when I'm trying to refresh with a minor version, the document gets executed twice for some reason and gets +2 versions, not sure if has anything to do.


The rendition retrying transactions fail due to ConcurrencyFailureExceptions but then they retry and succeed without further issues.


Can somebody point me what are we doing wrong or what could be the problem here?


Please let me know if you need any more information,

Thank you very much.