Automate With Confidence: Prevent Duplicate Workflow Executions
detail.loadingPreview
Ensure your automated processes run smoothly and without error by preventing duplicate workflow executions. This workflow uses Redis to implement a robust locking mechanism, safeguarding your critical operations.
About This Workflow
This n8n workflow intelligently prevents the simultaneous execution of identical tasks by leveraging Redis for distributed locking. When an incoming webhook triggers the workflow, it first attempts to acquire a unique lock in Redis based on the incoming data. If the lock is already held, the request is recognized as a duplicate and discarded. If the lock is acquired successfully, the workflow proceeds to execute its defined tasks. Upon completion, the lock is automatically released, allowing subsequent legitimate requests. This ensures data integrity and prevents resource exhaustion by avoiding redundant processing.
Key Features
- Redis-Powered Locking: Utilizes Redis's atomic operations to reliably acquire and release locks, ensuring exclusive access.
- Duplicate Request Detection: Identifies and discards incoming requests that match an active lock, preventing concurrent execution.
- Configurable Lock Expiration: Sets a Time-To-Live (TTL) on Redis locks to automatically release them, preventing deadlocks.
- Flexible Webhook Integration: Seamlessly integrates with incoming webhooks to trigger the locking mechanism.
- Clear Workflow Visualization: Includes sticky notes to explain the locking logic and the purpose of key nodes.
How To Use
- Incoming Webhook: Configure an
Incoming Webhooknode to receive data that will initiate your workflow. Ensure the payload structure is understood. - Fetch Webhook Data & Declare lockValue: Use a
Codenode to parse the incoming webhook payload. Extract relevant data points (e.g.,var1,var2,var3) and construct a uniquelockValuestring, such as${var1}-${var2}-${var3}. - Check Redis Lock: Add a
Redisnode configured for the 'GET' operation. Set thekeyto a consistent value (e.g.,xyz-lock) and map thelockValuefrom the previous step to the Redis key. Configure the node to store the result in a new property (e.g.,Element). - Redis Lock Existence (IF Node): Use an
IFnode to check if theElementproperty retrieved from Redis is empty (emptyoperator). If it is empty, it means no lock exists. - Acquire Redis Lock (IF True Path): If the lock does not exist, connect to the
IFnode's 'true' output. Add aRedisnode configured for the 'SET' operation. Use the samekeyas before. Set thevalueto thelockValuegenerated in step 2. Configureexpiretotrueand set attl(e.g., 180 seconds) to prevent deadlocks. - Workflow Execution (After Acquire Lock): Connect the 'true' output of the 'Acquire Redis Lock' node (or the 'true' output of the 'Redis Lock Existence' IF node if it bypasses the acquire step and goes straight to execution) to your main workflow logic (represented by
Workflow 1,Workflow 2,Workflow 3in the snippet). These can be any n8n nodes you need to execute. - Discard Redis Lock (After Workflow Execution): After your main workflow logic has completed, add a
Redisnode configured for the 'DELETE' operation. Use the samekeyused for locking to remove the lock from Redis, making it available for future requests. - Handle Duplicate Requests (IF False Path): Connect the 'false' output of the 'Redis Lock Existence' IF node to a
NoOpnode or a notification mechanism to indicate that the request was a duplicate and discarded.
Apps Used
Workflow JSON
{
"id": "ceb82417-f6b2-4a9f-ac77-38c71ad6b0bb",
"name": "Automate With Confidence: Prevent Duplicate Workflow Executions",
"nodes": 16,
"category": "DevOps",
"status": "active",
"version": "1.0.0"
}Note: This is a sample preview. The full workflow JSON contains node configurations, credentials placeholders, and execution logic.
Get This Workflow
ID: ceb82417-f6b2...
About the Author
SaaS_Connector
Integration Guru
Connecting CRM, Notion, and Slack to automate your life.
Statistics
Related Workflows
Discover more workflows you might like
Automate Qualys Report Generation and Retrieval
Streamline your Qualys security reporting by automating the generation and retrieval of reports. This workflow ensures timely access to crucial security data without manual intervention.
Robust Concurrency Control for n8n Workflows with Redis
Prevent simultaneous execution of critical n8n workflows or tasks using a centralized, Redis-backed locking mechanism. This reusable utility workflow ensures data integrity and resource management by allowing other workflows to acquire, check, and release locks.
Automated PR Merged QA Notifications
Streamline your QA process with this automated workflow that notifies your team upon successful Pull Request merges. Leverage AI and vector stores to enrich notifications and ensure seamless integration into your development pipeline.