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:
- 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.
- Processing rows in a loop so one execution will process more than one row.
- 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:
Add Wait node with random wait amount to slow down execution a bit for demonstration purposes:
And also replace Manual Trigger node by Schedule Trigger node with trigger interval of 5 minutes:
So finally our 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:
So the last thing to do is to set workflow timeout to the same value as scheduling interval:
Let's check again. Now we can see that there are no more concurrent executions:
And once the previous execution did some job, the next execution will continue with the row where the previous one was stopped:
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.