I am trying to ensure sequential execution of my workflows in n8n, but I’m facing an issue where multiple workflows are being executed almost simultaneously, leading to overwriting data in my Google Sheets. This happens because the second execution starts before the first one finishes.
I want to ensure that each execution waits for the previous one to complete before starting. Is there a way to enforce sequential execution for my workflows?
You can use the /execution to get the execution data of your workflow, if theres an execution that are still running then you can use that to maybe wait a certain second and then check again after
you can enable the n8n API and access the n8n API Playground in the settings - n8n API
Can this approach be used on n8n Cloud as well, or is it only for self-hosted?
My understanding is that, the only way to get queue-like behavior, is to poll the n8n API (e.g., GET /executions?status=running&workflowId=...) and wait until no executions are running before starting the next one. Is that correct?
Is there really any built-in setting that forces a workflow to run one execution at a time / prevents overlaps on Cloud?
So this is the solution I am using but it still doesn’t work.
Basically I have this 2 executions that started at the exact same time, each with their own ID.
If the implementation works correctly it should show in the list of execution generated by ID#14340 the information of ID#14339. But what I am getting at the moment is that because they start at the exact same time, they see only themselves as the latest execution, so on eachone’s output I get data up to ID#14338.
So I dont think that I can get one of 2 executions that stared at the exact same time to wait for the other one to finish before it executes itself.
If there is no correct way to check if executions are still running, could i at least make dealy the rate at which speed the webhook returns or gets data?
I have solved my problem by using rabbitMQ, at the moment this seems to be the only way to ensure a sequential execution of a workflow / creating concurrency for executions in a workflow. It can even be done in cloud, just host your rabbiyMQ using some free provider (in my case CloudAMQP) and it’s all done. Only thing is that you will need two workflows (basically cutting in two pieces your original workflow):
-a workflow that takes from your webhook or other trigger data and pushes it in the queue
the rest of the original workflow now starts with the rabbitMQ trigger, that activates for each entry in the queue.