03-29-2017 08:31 AM
Hi,
Calling method: repositoryService.saveModel() of act_re_model, throws ActivitiOptimisticLockingException when it is called from two different Service layers having different transactions (there is no chance of Transaction being persisted).
I have calls to the method initiated from application to application, hence the previous transaction has to be committed.
But then the second call from application to application, redirected to Service layer and then calling this method, however throws the mentioned exception with below error:-
Optimistic locking exception : org.activiti.engine.ActivitiOptimisticLockingException: org.activiti.engine.impl.persistence.entity.ModelEntity@5c7a4bf8 was updated by another transaction concurrently
I have even tried to use NOT_SUPPORTED Spring propogation annotation on the method that makes first call to the saveModel() method and also REQUIRED and REQUIRES_NEW, but none works.
Even before the second call to saveModel() method, I have ensured that there is no lock acquired on ACT_RE_MODEL by previous databaseTransaction (when I called saveModel() for the first time, the dbTransaction is going to occur).
Any help will be appreciated.
Thanks,
Ami Dave
03-29-2017 04:34 PM
Hi Ami Dave,
Which Activiti version are you on?
Also, it would be easier for everybody if you can attach a unit test. This is important for people to spot where in your code that you are trying to access the same resource concurrently. Have you looked at the definition of this exception in Activiti? ActivitiOptimisticLockingException (Activiti - Engine 5.22.0 API)
You said
I have calls to the method initiated from application to application, hence the previous transaction has to be committed.
But then the second call from application to application, redirected to Service layer and then calling this method, however throws the mentioned exception with below error:-
Are you sure that you are not calling 'saveModel' at the same time or concurrently? You know this has to be well-controlled by the application right?
Hope this helps,
Thong
03-30-2017 09:15 AM
Hi,
Our current Activiti Framework Version is 5.15
Actually I feel it is easy to detremine that if I make a server-to-server (application-to-application) call then previous Transaction has to be committed. And I can see the changes in database tables, even I can't find any table is still locked after first call.
Hence there is some issue from Activiti itself that it isn't committing the previous transaction of saveModel somwhow, I have tried to put delay of 3mins as well once first call is back to the initiator server, but still getting same Exception on second call to saveModel.
Is there any way to handle this situation?
Thanks,
Ami Dave
04-04-2017 03:02 AM
Hi Ami Dave ,
I don't quite understand your system topology when you said 'server-server (application-application)'. Can you describe your Activiti topology more clearly?
I have tried to put delay of 3mins as well once first call is back to the initiator server, but still getting same Exception on second call to saveModel.
Of course this doesn't solve the problem. This is very bad programming practice.
Unless I understand more about your setup and how to reproduce your issue (with a unit test), there's nothing I can do to help you.
Cheers,
Thong Huynh
Explore our Alfresco products with the links below. Use labels to filter content by product module.