Mutex Lock
Ensures exclusive access to a critical section of the workflow via a distributed lock.
Experimental. Computes a lock key and passes the payload through out; no lock is acquired, because the engine never reads the lock request.
When multiple workflow instances (or parallel branches) try to access a shared resource simultaneously, a Mutex (Mutual Exclusion) ensures only one can proceed at a time. Other instances will wait until the lock is released or a timeout occurs.
Behavior:
- Acquire: Attempts to lock the key. If free, lock is granted.
- Wait: If locked, the process spins/waits.
- Release: The lock is automatically released after the TTL expires (to prevent deadlocks).
Use Cases:
- Preventing double-spending on a user wallet.
- Serializing access to a legacy system that cannot handle concurrency.
- Ensuring "Check-then-Act" atomicity in database operations.
How it works
- Resolves the config;
ttl_secondsdefaults to 30. - If the original
key_exprtext contains{{, the resolved value is used as the key (converted to a string). Otherwisekey_expris evaluated as JSONata against the payload (user_id); a falsy result or nokey_exprgivesglobal_lock. - Returns the payload unchanged through
outwithmeta.mutex{ action: "acquire", key, ttl }. - The engine ignores
meta.mutex: nothing is locked, nothing waits and concurrent runs are not serialized.
In a workflow
The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.
{
"node_id": "node-lock-user",
"label": "Lock user",
"operator_slug": "flow.mutex",
"operator_version": "1.0.0",
"config": {
"key_expr": "{{ $json.user_id }}",
"ttl_seconds": 30
}
}{
"ok": true,
"data": {
"user_id": "u-42",
"action": "export"
},
"port": "out",
"meta": {
"mutex": {
"action": "acquire",
"key": "u-42",
"ttl": 30
}
}
}Configuration
-
key_exprstring Required Accepts expressions -
JSONata expression to derive the unique lock ID (e.g. `data.userId`).
-
ttl_secondsinteger Optional -
Safety timeout to automatically release the lock if the workflow crashes.
Its configuration shows the shared execution settings, but this node does not apply retries (retryOnFail, maxTries) yet. continueOnFail is not applied by any node.
Behaviour in the code
What the implementation does with these keys beyond what the schema says.
-
ttl_seconds - Only echoed in
meta.mutex.ttl.
Output ports
out default Always, including when the JSONata key fails (see errors).
{
"user_id": "u-42",
"action": "export"
}timeout Never emitted.
error Never emitted.
In expressions
What a later node can read from this node's output with $("Mutex Lock").item.json.<path> (write your node's label instead of Mutex Lock). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through out, from the output shown in Ports.
| Expression | Editor | Worker |
|---|---|---|
$("Mutex Lock").item.json.payload | — | |
$("Mutex Lock").item.json.user_id | — | |
$("Mutex Lock").item.json.action | — |
— Editor: The editor suggests it, but the worker does not return it: it reads as undefined.
— Worker: The worker returns it but the editor does not suggest it: write it by hand. Keys inside objects can depend on your data or configuration (for example one key per label).
Errors
| Message | Port | Cause and fix |
|---|---|---|
Lock key evaluation failed | out | key_expr is invalid JSONata. The envelope has no port, so the engine routes it to out and the next node receives { ok: false, errors: ["Lock key evaluation failed"] } as its payload. |
Input contract
-
payloadobject Optional
Output contract
-
payloadobject Optional
Contracts (JSON Schema)
The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.
{
"slug": "flow.mutex",
"name": "Mutex Lock",
"category": "flow",
"version": "1.0.0",
"description": "Ensures exclusive access to a critical section of the workflow via a distributed lock.\n\n When multiple workflow instances (or parallel branches) try to access a shared resource simultaneously, a Mutex (Mutual Exclusion) ensures only one can proceed at a time. Other instances will wait until the lock is released or a timeout occurs.\n\n **Behavior:**\n - **Acquire:** Attempts to lock the key. If free, lock is granted.\n - **Wait:** If locked, the process spins/waits.\n - **Release:** The lock is automatically released after the TTL expires (to prevent deadlocks).\n\n **Use Cases:**\n - Preventing double-spending on a user wallet.\n - Serializing access to a legacy system that cannot handle concurrency.\n - Ensuring \"Check-then-Act\" atomicity in database operations.",
"capabilities": [
"locking",
"concurrency",
"safety"
],
"config_schema": {
"type": "object",
"properties": {
"key_expr": {
"type": "string",
"title": "Lock Key",
"format": "expression",
"description": "JSONata expression to derive the unique lock ID (e.g. `data.userId`)."
},
"ttl_seconds": {
"type": "integer",
"default": 30,
"title": "Lock TTL (Seconds)",
"description": "Safety timeout to automatically release the lock if the workflow crashes."
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
},
"required": [
"key_expr"
]
},
"input_contract_schema": {
"type": "object",
"description": "Payload to evaluate the key against.",
"properties": {
"payload": {
"type": "object"
}
}
},
"output_contract_schema": {
"type": "object",
"description": "Passes through the original payload.",
"properties": {
"payload": {
"type": "object"
}
}
},
"ports": [
{
"port_id": "out",
"label": "Acquired",
"is_default": true,
"description": "Lock successfully acquired. Proceed with critical section."
},
{
"port_id": "timeout",
"label": "Timeout",
"description": "Failed to acquire lock within the system limit."
},
{
"port_id": "error",
"label": "Error",
"description": "System error during locking."
}
],
"execution_mode": "sync",
"tags": [
"lock",
"mutex",
"atomic",
"concurrency"
],
"is_stateful": true,
"publisher": {
"identity": "org_sommatic_ai",
"profile": {
"name": "Sommatic AI",
"verified": true,
"url": "https://me.veripass.com/sommatic",
"logo_url": null
}
}
}{
"type": "object",
"properties": {
"key_expr": {
"type": "string",
"title": "Lock Key",
"format": "expression",
"description": "JSONata expression to derive the unique lock ID (e.g. `data.userId`)."
},
"ttl_seconds": {
"type": "integer",
"default": 30,
"title": "Lock TTL (Seconds)",
"description": "Safety timeout to automatically release the lock if the workflow crashes."
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
},
"required": [
"key_expr"
]
}{
"type": "object",
"description": "Payload to evaluate the key against.",
"properties": {
"payload": {
"type": "object"
}
}
}{
"type": "object",
"description": "Passes through the original payload.",
"properties": {
"payload": {
"type": "object"
}
}
}[
{
"port_id": "out",
"label": "Acquired",
"is_default": true,
"description": "Lock successfully acquired. Proceed with critical section."
},
{
"port_id": "timeout",
"label": "Timeout",
"description": "Failed to acquire lock within the system limit."
},
{
"port_id": "error",
"label": "Error",
"description": "System error during locking."
}
]Execution
- Execution
sync- Stateful
- Yes
- Retries (
retryOnFail) - No
- Capabilities
lockingconcurrencysafety- Tags
lockmutexatomicconcurrency
Notes and limits
- Not implemented: the engine has no lock store. Do not rely on this node for mutual exclusion; make the protected operation idempotent instead.
metais recorded in the run steps only: downstream nodes receivedataas their payload and cannot readmetathrough$jsonor$("Node").
Reviewed against the orchestrator code · 31e874b · 2026-11-26