Skip to main content

Locks Actions

Locks actions enable you to coordinate access to shared resources and prevent race conditions. This is essential for implementing the Exclusivity Pattern in your workflows.

Available Operations

Lock Actions

  • Acquire a lock - Request exclusive access to a resource
  • Check if a lock exists - Verify if a resource is currently locked
  • Release a lock - Free a resource for other processes

Acquire a lock

Request exclusive access to a resource.

Acquire Lock Configuration

ParameterTypeRequiredDescription
Lock NameStringYesUnique name for the lock
TimeoutStringNoMaximum time to wait for lock (e.g., "30s")
TTLStringNoHow long to hold the lock (e.g., "5m")
MetadataObjectNoAdditional data to store with the lock

Acquire Lock Example

{
"key": "file-processing-12345",
"ttl": 300
}

Acquire Lock Response

{
"success": true,
"data": {
"id": "lock123",
"key": "file-processing-12345",
"appId": "app123",
"expiresAt": "2024-01-01T10:05:00.000Z",
"createdAt": "2024-01-01T10:00:00.000Z"
}
}

Release a lock

Free a resource for other processes.

Release Lock Configuration

ParameterTypeRequiredDescription
Lock NameStringYesName of the lock to release
Lock IDStringYesID of the lock to release

Release Lock Example

{
"key": "file-processing-12345"
}

Release Lock Response

{
"success": true,
"data": {
"released": true,
"key": "file-processing-12345",
"releasedAt": "2024-01-01T10:00:00.000Z"
}
}

Check if a lock exists

Verify if a resource is currently locked and get lock details.

Check Lock Configuration

ParameterTypeRequiredDescription
Lock NameStringYesName of the lock to check

Check Lock Example

{
"key": "file-processing-12345"
}

Check Lock Response

{
"success": true,
"data": {
"exists": true,
"lock": {
"id": "lock123",
"key": "file-processing-12345",
"appId": "app123",
"expiresAt": "2024-01-01T10:05:00.000Z",
"createdAt": "2024-01-01T10:00:00.000Z"
}
}
}

Common Patterns

Exclusivity Pattern

Implement the exclusivity pattern for resource coordination:

  1. Acquire lock for resource
  2. If acquired: Process resource
  3. Release lock after processing
// Step 1: Acquire Lock
{
"key": "file-processing-{{ $json.filename }}",
"ttl": 300
}

// Step 2: Process if lock acquired
// (Use IF node with condition: 8kit.data.id exists)

// Step 3: Release Lock after processing
{
"key": "file-processing-{{ $json.filename }}"
}

Lock Timeout

Handle cases where locks cannot be acquired:

{
"key": "resource-123",
"ttl": 120
}

Next Steps

Ready to explore more actions? Check out:

  1. Last Updated Actions - Enable incremental polling
  2. App Info Actions - Monitor system health