OptimisticLockingException while completing the task

We are experiencing a lot of OptimisticLockingException while user trying to complete the camunda Task.
We are completing the task by using taskService.complete(taskId);
We have sequence of user task in camunda workflow, user task are not using async before and async after in camunda workflow modal. (we dont any process task). User task has create , complete , assignment listener attached to it.
We are using camunda-bpm-spring-boot-starter-root version 3.2.0 that uses the camunda engine version 7.10.0.
We are using mariaDB as database.
Is it a known issue with a camunda engine , if the version upgrade is going to fix the issue . Let me know for any resolution.

Hi @rahuljain7th,

welcome to the forum. :wave:

Please check out our documentation on Optimistic Locking and the scenarios in which an exception might occur.

In general, this is due to concurrent modification of an entity, for example a specific variable that two tasks are updating in parallel. As this seems to reliably occur when tasks are completed, I assume you should scan your process(es) for potential parallel modification of elements like variables.

Hope that helps.

Best,
Tobias

we don’t have any parallel task . but we have the listener attached to the task. Also This is happening when a user completes the task for first time and the request gets hanged for some time and task doesn’t get completed , so user retries for the second time , and second time request completes . As soon as second retry request completes, first one throws the optimistic locking exception and fails to rollback transaction.
So we see duplicate task for next one.

for e.g we have this sequence taskA —> taskB
when taskA is completed first time , request hangs
user retries to complete task A again in second time - it is successfully completes and first request which was hanged throws optimistic locking exception and the rollback of first task fails.

So we see duplicate taskB instead one taskB. Any help would be appreciated in this.

Also task A and taskB has create , assignment listener .
in Create Listener we are using taskService.getVariables.

we don’t have any parallel task . but we have the listener attached to the task. Also This is happening when a user completes the task for first time and the request gets hanged for some time and task doesn’t get completed , so user retries for the second time , and second time request completes . As soon as second retry request completes, first one throws the optimistic locking exception and fails to rollback transaction.
So we see duplicate task for next one.

for e.g we have this sequence taskA —> taskB
when taskA is completed first time , request hangs
user retries to complete task A again in second time - it is successfully completes and first request which was hanged throws optimistic locking exception and the rollback of first task fails.

So we see duplicate taskB instead one taskB. Any help would be appreciated in this.

Also task A and taskB has create , assignment listener .
in Create Listener we are using taskService.getVariables