Skip to main content
Community Hub

Distributed locking

TL;DR

Frequently asked questions about distributed locking in the Application SDK including decorator usage, testing, and configuration.

Your AI can read this via Docs MCPcurl -fsSL "https://docs.atlan.com/install-docs-mcp" | bashConnect

Common questions about using distributed locking with the @needs_lock decorator in Application SDK workflows.

Can I use locks inside my activity code?​

No, distributed locks only wrap entire activities. You can't acquire or release locks from within your activity implementation. The @needs_lock decorator handles all lock management automatically. This design requires planning activity boundaries around locking requirements.

Can I lock entire workflows?​

No, distributed locks can't coordinate at the workflow level. You can't apply @needs_lock to workflow definitions. Each activity within a workflow must manage its own locking strategy independently.

What happens if Redis goes down?​

Lock acquisition fails with retryable errors. Temporal retries until the workflow timeout. Existing locks expire via TTL, so no locks are orphaned. A standalone Redis instance represents a single point of failure. If Redis becomes unavailable, all distributed locking ceases to function. Consider using Redis Sentinel for high availability with automatic failover.

Can I change max_locks at runtime?​

No, max_locks is set at decoration time and can't be changed dynamically at runtime. You must redeploy your application to change lock limits.

Do I need to specify timeouts for locked activities?​

Yes, all activities with @needs_lock must specify schedule_to_close_timeout. The system uses this timeout to calculate lock TTL and prevent deadlocks.

How do I handle different environments?​

Use different Redis instances or databases for each environment:

# Production
export REDIS_HOST=prod-redis.example.com
export REDIS_DB=0

# Staging
export REDIS_HOST=staging-redis.example.com
export REDIS_DB=0

# Development
export REDIS_HOST=localhost
export REDIS_DB=1

Can different applications share lock names?​

No, lock names are automatically scoped by APPLICATION_NAME. Different applications can use the same lock name without interference.


Need help​

If you can't find the answer you're looking for, contact Atlan support: Submit a request.

See also​