Use this robust n8n workflow template utilizing Redis to implement locking mechanisms, preventing concurrent execution of critical automation tasks in your n8n workflows.
Download this n8n workflow template and start using it instantly.
Automation developers building highly available n8n workflows.
Users requiring synchronization for critical tasks (e.g., database updates or expensive API calls).
Complex business processes often require synchronization to prevent data corruption or resource overload caused by simultaneous execution. This n8n workflow template provides a robust solution by leveraging Redis as a centralized locking service. When a master n8n workflow starts, it attempts to acquire a lock (set a key in Redis). If the key already exists, the execution stops, preventing concurrent runs. Once the process finishes, the lock is released (key is unset). This reusable n8n workflow handles the entire Redis interaction logic (Get, Set, Unset) via an Execute Workflow Trigger node, allowing any other n8n workflow to easily manage concurrency using simple input parameters.
This powerful n8n workflow is designed to be called by other n8n workflows (using the Execute Workflow node) to manage process state in Redis.
The automation starts with the When Executed by Another Workflow n8n trigger, expecting inputs for action (get, set, unset), key, value, and timeout. The Set Timeout node ensures a 600-second default expiration for the lock.
Routing: A Switch n8n node inspects the action input to determine the required Redis operation.
get action: The Get Key n8n node retrieves the status of the specific process key from Redis. If the result is null, the process is free to run.
set action: The Set Key n8n node creates or updates the key with the specified value (e.g., "working") and sets a TTL (timeout), acquiring the lock.
unset action: The UnSet Key n8n node deletes the key from Redis, releasing the lock.
The example section shows how a separate n8n workflow can use this logic:
When clicking ‘Test workflow’) starts the execution.Execute Workflow n8n node calls the Redis logic with action: get to check for an existing lock.If n8n node checks if the output from Redis is empty. If it finds an existing key (meaning the workflow is already running), the flow executes the Stop and Error n8n node, halting the execution.Execute Workflow n8n node with action: set to acquire the lock.No Operation and Wait nodes).Execute Workflow n8n node with action: unset releases the lock, making the n8n workflow template ready for the next execution.To deploy this comprehensive n8n workflow, follow these steps:
Get Key, Set Key, and UnSet Key Redis n8n node instances (in the center column). You must configure a valid Redis credential for each.Execute Workflow Nodes: This template uses the Execute Workflow n8n node to call itself recursively. You must update the Workflow ID in all Execute Workflow nodes (like Is Workflow Active, Set Workflow Active, etc.) to point to the ID of this newly imported n8n workflow. The ID is visible in the browser URL when editing the workflow.When clicking ‘Test workflow’ n8n trigger to test the locking mechanism. Running it twice quickly should result in an error on the second run. When Executed by Another Workflow (n8n Trigger): Serves as the entry point for the reusable Redis locking logic, accepting dynamic inputs (action, key, value, timeout) from other n8n templates.
Set Timeout (n8n node): Ensures that the lock acquired in Redis has a default Time To Live (TTL) of 600 seconds, preventing indefinite lock retention if the workflow fails.
Switch (n8n node): Routes the execution based on the desired action (get, set, or unset), directing the flow to the appropriate Redis operation.
Redis (Get Key, Set Key, UnSet Key) (n8n node): These are the core locking nodes. They interact directly with the Redis instance to perform key retrieval (get), key setting with expiration (set), and key deletion (delete/unset). Keys are dynamically named using the input key (e.g., processstatus{{ $json.key }}).
Execute Workflow (n8n node): Used in the example sections to call the core Redis logic with specific parameters (e.g., checking for an existing lock with action: get, or acquiring a lock with action: set).
If (n8n node): Crucial for the concurrency check. It inspects the output of the 'get' action. If the Redis key exists (output is not empty), it prevents the workflow from continuing by routing to the Stop and Error n8n node.
Learn how to prepare, clean, and map data fields using the crucial Set n8n node before performing an efficient upsert operation into Google Sheets. This practical n8n workflow demonstrates essential data handling.

Implement a proactive health alert system using a sophisticated n8n workflow. This n8n template analyzes vital signs with GPT-4, calculates dynamic risk scores, and automates urgent notifications via SMS and Slack.

Automate HDB flat price forecasting using this advanced n8n workflow. Integrates GPT-4o, time series analysis, and statistical modeling, saving predictions to Google Sheets.

Use this robust n8n workflow to prevent duplicate processing by centrally managing item states in Redis. Features include automatic troubleshooting links and detailed audit logging.

Secure your AI applications against prompt injection and malicious inputs using this advanced, multi-layered GPT-4O security n8n workflow. Includes moderation, sanitization, and quality assurance steps.








































