Try to handle race condition for process variables

Hi guys! I have the following situation:
In my main process, I have a bunch of variables that mark precise status. When they are created they all have the value ‘In Progress’. For every status variable, there is another process that can update this variable, by doing REST call, at any time, so there is a bunch of processes that run in parallel and aren’t connected with the main process. I can’t finish my main process until all these status variables will be equal to ‘Complete’ or ‘Error’. So at the end of my main process, I put an intermediate conditional catch even that runs inline script anytime when some variable is updated, and here is one problem. Sometimes it happens like this: 1. Let’s say we have two status variables and two processes that run in parallel and can update status variables at any time by doing REST call. 2. These two processes update their variables almost at the same time (with 1-2 milliseconds difference). So, when the first of these variables was updated my intermediate conditional catch event starts to execute a script, and while the script is executing the second variable is also updated, but script work with an old value. So script returns false and doesn’t run again because when he was finished the second variable was already updated. It’s a typical race condition situation and I would like to know if there is some way to handle situation like this on Camunda side. Thanks for your help in advance.

Hi @Yurii_Shchur
Welcome to the forum.

Can you maybe upload some models that can help me understand that question better?
I think it have an idea of what it is you’re looking for but a model would really help i think.

-Niall

Hi @Niall
Thanks for answering.

Here you can see the model of my situation. ExampleDiagram.bpmn (13.8 KB)