A race condition is when multiple transactions are happening at more or less the same time, and they conflict.
Let’s say both transaction A and B look to see if a record exists. If it doesn’t, they create it. Now if A and B happen virtually simultaneously, they both create records and therefore cause duplicates.
This happens in various scenarios and can be frustrating to identify.
Depending on the situation, there are various ways to remedy this. The first step is obviously to identify the issue as a race condition.
Then it’s to introduce timeouts or additional verifications before creating something.
A recent example I’ve encountered is when an integration creates multiple records. There’s a record-triggered flow that immediately calls a subflow to perform an action.
Rather than immediately call the subflow, consider adding a scheduled path. The timeout could be as little as 1 minute. As you may know “1 minute” doesn’t usually mean “exactly 1 minute”. The difference may help.
To visual this,
The takeaway
Race conditions can be avoided by further checks and timeouts.