Redis Lock Node

Hi everyone,

I’m building a workflow in n8n with two agents:

  1. Planner agent — inserts plan to a database and should trigger an executor if no active task exists for a user.

  2. Executor agent — executes the plan when triggered.

The logic is:

  • Insert a new plan in DB.

  • Check if there’s an active task for the same user.

  • If no active task, trigger executor.

  • If active task exists, do nothing.

The problem happens when two plans are created at the same time for the same user:

  • Workflow A inserts plan 1.

  • Workflow B inserts plan 2.

  • Both workflows check Redis/DB and see no lock/active task.

  • Both assume no active task and skip triggering executor.

So both tasks get stuck and never run.

To fix this, I tried using Redis as a lock, but n8n’s built-in Redis node doesn’t support atomic locking (SET key NX EX ttl) directly.

Questions:

  1. What’s the correct way to implement an atomic Redis lock in n8n so that only one workflow execution can acquire it per user?

  2. Are there any recommended solution to the issue I just described?

Any example workflows or configuration tips are appreciated!

Thanks!

Information on your n8n setup

  • n8n version: 1.122.5
  • Database (default: SQLite): Supabase Postgres
  • Running n8n via (Docker, npm, n8n cloud, desktop app): n8n cloud

Hey @trvp !

Welcome to n8n community!

From what I understand you are trying to achieve sequential execution…

Queue mode with Redis and RabbitMQ i think this is strong combo.

Check this topic :

Cheers!

1 Like

Thanks for the reply! My team decided to go for a different approach. But what you shared looks like it can solve the question I posted.