Sunday, July 20, 2025

Tip #6: Preventing simultaneous executions of scheduled workflow

Let's assume you have n8n workflow which is managed by Google Sheet similar to the approach described in my previous posts Tip #2: Using Google Sheets as UI for your n8n workflow and Tip #5: Fixing Google Sheets quota exceeding issue. So you have big and dynamic amount of rows with different statuses and your workflow should automatically process with them accordingly.

In this case pretty good solution could be:

  1. Scheduling workflow to execute at some small time intervals (i.e. every 5 minutes) so the maximum delay between your change in Google Sheet and workflow execution will be small enough.
  2. Processing rows in a loop so one execution will process more than one row.
  3. Updating Google Sheet right after each row processed so you will not loose previous rows data in the case of error.

So let's start from the workflow from Tip #5: Fixing Google Sheets quota exceeding issue:

Starting with n8n workflow which updates Google Sheet rows in a loop

Add Wait node with random wait amount to slow down execution a bit for demonstration purposes:

Adding Wait node with random wait amount in n8n

And also replace Manual Trigger node by Schedule Trigger node with trigger interval of 5 minutes:

Adding Schedule Trigger node with trigger interval of 5 minutes in n8n

So finally our workflow should look like this:

Finally our n8n workflow should look like this

Now we are ready to execute our n8n workflow and see. At some point there are two concurrent executions which actually do the same job:

Two concurrent executions of n8n workflow which do the same job

So the last thing to do is to set workflow timeout to the same value as scheduling interval:

Setting n8n workflow timeout to prevent concurrent executions

Let's check again. Now we can see that there are no more concurrent executions:

There are no more concurrent executions of n8n workflow

And once the previous execution did some job, the next execution will continue with the row where the previous one was stopped:

Google Sheet for managing n8n workflow

So that's the idea to use scheduling and timeout with the same time interval. Works nicely!

You can find the template for the described approach here.

No comments:

Post a Comment