# Race Conditions in Workflows (Unexpected Behavior)

While rare, a race condition is when two servers update the status of a contact within seconds of each other. One server updates the contact and the other server overwrites the first one. This can result in duplicate messages or an action showing that it has been executed but does not reflect for the contact. This can cause loop lockouts and other unexpected behavior to occur with workflows.

Please take a look at our _Loop Lockout_ article as it’s a related topic

**Common Race Condition causes:**

* Multiple triggers for the same action
* Actions being executed at the same time for a contact
* Executions happening within automations for the same contact with similar timing

**Example:** Using both the Appointment Status and Customer Booked Appointment triggers to perform the same function will cause conflicts. Keep in mind Customer booked appointment is a deprecated trigger and you should use the appointment status trigger.

**Example:** Using opportunity changes and appointment triggers in the same workflow that fire off simultaneously.

**Example:** A contact tag being added at the same time in multiple places

**How do you know it's a race condition?**

* Investigating workflow execution History/Status + Time and finding issues based on similar timing
* Repeating the same process and the tag is being added without it reflecting in the account
* Duplicate messages and workflow history reflect a different trigger than intended due to timing
* Unexpected behavior due to timing

Example: A Contact tag trigger firing off instead of an appointment trigger because they are in the same workflow and happened at a similar time.

Example: You are adding the contact to a separate workflow with a tag that also has other triggers that fire with similar timing. Using a Contact tag trigger and then expecting the appointment data to display correctly in an email using custom values. (Membership and Appointment custom values are dependent on their related triggers)

**How can I prevent them from happening?**

* Adding a 2 min wait step above the race-affected actions, as this will allow the system to process the action correctly
* Do not use the same trigger or similar triggers on one/multiple workflows for the same actions
* Be specific with your filters and keep in mind the action the lead would take and how the workflow would fire when that happens.
* Do not use unspecific and similar triggers in one/multiple workflows
* Pay attention to the timing and watch out for triggers firing at the same time
* Use the PASS INPUT TRIGGER PARAMETERS with the _Add To Workflow_ action when adding to another workflow when attempting to pass in values and data

**Unexpected Behavior**

* An execution showing that it happened in the workflow but it does not reflect in the contact card
* Loop Lockouts
* Duplicated messages sending
* Multiple workflows firing off unexpectedly
* Membership or Appointment information not populating or displaying _undefined_ in a message

**Best Practices and Troubleshooting**

* Check Workflow History and Execution Logs

{% embed url="https://lh4.googleusercontent.com/SQMyvmidCjD0YVCK8EV__274xmggYd4trv6ZshdXGJD5jcmMbJ18IszY6mOV9xQ-ZfJv907tr5ueyVfVRPRusZbbpHJez4kGt2P5te_dndowkwezoIVDloHfeFTs-Bg81mrWM0wFSgjNlwgxY7WUD80" %}

* Check the _added to workflow_ execution in the workflow and the action details, especially regarding timing

{% embed url="https://lh3.googleusercontent.com/PGU4GS95s1L_XXN8SEX6Evpslwkl1jbpeZX7Snnqr2a12b4SZuHaCmtJt-xRlMKhmhXYYSTfPPqw4pVgsEtTVn93pHHbjtdiiN-6XFphkJuwfc33yYTT1th17_Fp-PlzJB3HxggMbokBVVTDJQaQauo" %}

{% embed url="https://lh4.googleusercontent.com/SLQ0iMr9m0Qy3czp-B__lANrbkVHMCV4DlactgVmK-ohZ_YNKr8HdToToj2IZHLlJYJuloWYHzq9nldSa7Tlj41zkolbcI_uQfAlqcmNzqan6CvdONNbG43yEntfDvxB8veeWLlTMdFL7jI046k9L_8" %}

* Add a wait step of 2 minutes before actions that may cause conflicts to offset these issues

{% embed url="https://lh4.googleusercontent.com/9Tw8Ej5aJupK1vrzkYV-9qNHaKiPXo1LGpmtZZAB7DJZc1GyjUUOg_aQz-qtolLtao5wlBY0N55H86At0Uz7abwvNMGhupUz0BpSGJHG6n29U1lGtqsM1OBfBp-Dm2LDN9y_qZMdDyl2SF3kPH5RC3Y" %}

* Pay attention to the timing and watch for triggers firing at the same time
* Get more specific with your filters as an example filter for a specific calendar when using appointment triggers

{% embed url="https://lh3.googleusercontent.com/DPenHENmQLqzFDkQhZpbhR9g-m-I0zTj2J0JhiH9xCXsXnFfT95GrkzZUF69qo7nppaaTOVC4JlqJu-3vvbTjWbSQgIEv63JlOIW2HdJjmPsmhTA-yIsLafTQJTW0i9O_3RN6rHJSwFlfioKzZSBGEc" %}

* Investigate multiple workflows that fire off the same or similar triggers that may fire at the same time when an action by the customer is taken
* Use unique trigger-to-action implementations instead of multiple workflows for the same actions
* If you need to pass data between workflows, remember passing data on to other workflows won't happen with an Add tag action and its related trigger in a separate workflow. Use the Pass input parameters toggle with the _Add To Workflow_ action. This will take all the data in the workflow and pass it into the other workflow

{% embed url="https://lh6.googleusercontent.com/QFMYTtj1C5quMM8qkk2_iXj78wPRJ9nZo7b-u5Kbh5ojw4lpQaFYWkUKmdsEO1nhfYhq5Q3yLaQ9fxrnKjHVgLNgPhdrM0BkFisYDzoyQ7ZUvOhZ86qmezcaeQ0AGZyOAK9-Q-y3MIAFqFJPrUMx9Bg" %}

* If you are using Zoom and see "undefined" Check that the Zoom user is integrated with their profile, and check if Zoom is added to the user's group calendar. After that, if race conditions apply this may be due to the incorrect trigger adding a contact to the workflow.
* For appointments use the appointment status trigger + correct filters including STATUS
* When passing appointment data between workflows use Pass input parameters which will take all the data in the workflow and pass it into the other workflow
* Check added to workflow and what trigger was involved to know if data was passed correctly
