Zapier was working really well for us when we had just a few Zaps doing a few simple things. Because of that early success we started using Zapier for more and more automated tasks that are increasingly complex. Now I think we are running into issues where Zaps are stepping on each other but I can’t find anything online about the execution model that Zapier uses for controlling Zaps.
So we have two Zaps: Zap A & Zap B
Each Zap, when run “by itself”, works perfectly. The definition of “by itself” is when an instance of Zap A or B runs at a time when no other instance of Zap A or B will be executed for so much time later that it is essentially guaranteed that the first Zap A or B instance finishes before any other Zap A or Zap B instance could be run.
Both Zap A and B are straight forward, 1) Do Something, 2) Put a new entry in the same google sheet, 3) do some more stuff and exit. The google sheet is acting as a look up table so when a client finishes their part of the task, which might be between 1 minute or 1 month later, a Zap C & D can do a look up in the google sheet to bring context to the finished task, remove the google sheet entry, and move on.
The Issue is that when Zap A and B are triggered within a second of each other it appears they are stepping on each other’s toes when the google sheet operations of the Zap happens. So when the client part of both zaps finish we find out that one of the entries isn’t in the google sheet so one of the clean up Zaps C & D will fail and one will succeed.
So this brings up some questions that I can’t find anywhere. I believe Zapier should write a “Best Practices” or “How to design your Zaps” guide so that people can avoid these types of issues.:
- Can multiple instances of Zap A run at a time? So if Zap A’s trigger happens twice at essentially the same time, will one instance of Zap A from the first trigger run to completion and then the second trigger of Zap A will run? Essentially, when I write a Zap, can I make the assumption that it is impossible that another instance of Zap A will run at the same time? Or do I need to defensively design my Zaps to account for the potential of two instances of Zap A running at the same time? Basically, can I assume Zap A has a mutex around it?
- Can Zap A and Zap B run at the same time or does my Zapier instance require one zap to run at a time. If Zap A and Zap B are triggered at the same time will they run in separate threads of execution at the same time (and therefore, can easily step on each other if they are editing the same spreadsheet)? Based on behaviors I’ve seen I’m suspecting the answer is yes, they run at the same time, but I want to make sure.
- When you are operating on a single google sheet, if Zap A and Zap B operating on the same sheet at the same time, could their actions happen at the same time or are they queued up? So if Zap A and B both write an entry at the same time is there something in the Zapier engine that says “this is for the same sheet so queue up these writes so they happen one at a time” or could both those writes literally happen at the same time?
- Assuming Zaps are running at the same time, if Zap A is doing a “Find Row” at the exact same time as Zap B is doing a “Create Spreadsheet Row” are those instructions at least autonomous?
- How do I protect the reading and writing of the google sheet to guarantee that there is no way multiple Zaps could be operating on it at the same time. Delay on Queue seems promising but it’s description had a warning saying that delays in the services used in tasks after the queue make it so they can’t guarantee autonomous operations. Is there a way to put a “mutex” around a google sheet so I can do a look up followed by a write as a guaranteed autonomous action?