Process instance username taken errors

we have a process model to evaluate that runs when we get a request from an integration. We are having a problem For the addition of multiple groups to the same user.

Two process instances are generated simultaneously to add a user to different groups, and when one process instance checks if the user name is taken then it proceeds to create the user and the user is created, simultaneously other process instance is created for the same user to add the user to a different group at the same time. 

 

So when process instance A adds the user 1 to group 'a'  then process instance B is getting stuck because the username is taken by process instance A and it cannot proceeds as the node was false while checking is username taken.

 

We are getting this error because multiple process instances are triggered at the same time hence leading to an issue.

Can we give a 30 seconds timer for process instance A to completed before triggering process Instance B

Any help would be much appreciated. 

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer
    There might be a more graceful solution to this, but for a quick workaround, my idea is that you could make it such that each process instance checks at first if the username exists, and if it doesn't, pause for a random number of seconds (let's say between 1 and 30), then check again and proceed depending on what it finds.

    The idea here is that if 2 instances are generated simultaneously for username "asdf", both processes will pause for a random number of seconds - one of them might be 10 and the other might be 20. The instance that got the value of 10 will proceed to create the user and do the first group addition. The instance that pauses for 20 seconds, then, will re-check and find the user already exists, and just do the group addition instead of the user addition.