distributed-locking

Coordinate distributed processes with Redis, PostgreSQL, or Redlock locks.

Updated Mar 29, 2026
One-click install
npx skills add https://github.com/marquesfelip/agents-and-skills --skill distributed-locking
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: distributed-locking
Source: https://github.com/marquesfelip/agents-and-skills/tree/main/skills/distributed-locking
Command: npx skills add https://github.com/marquesfelip/agents-and-skills --skill distributed-locking

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Distributed coordination and locking across services to prevent concurrent execution of critical sections and ensure single-active workers.

Core Features & Use Cases

  • Redis-based distributed locking (SET NX) with TTL
  • Fencing tokens to prevent stale lock actions
  • PostgreSQL advisory locks for DB-bound operations
  • Redlock for multi-node Redis deployments
  • Common failure modes and mitigations

Quick Start

Use a Redis-based lock with a TTL around your critical section to ensure only one process runs at a time.

Frequently Asked Questions about distributed-locking

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement distributed locking with Redis to prevent concurrent execution in microservices?

Implement distributed locking in microservices using Redis SET NX commands with a TTL to ensure only one process executes a critical section at a time, automatically expiring stale locks to prevent deadlocks.

What are fencing tokens and why are they needed for distributed locks?

Fencing tokens are monotonically increasing values used with distributed locks to prevent stale lock actions. They ensure that delayed processes holding expired locks cannot overwrite data written by the current lock holder.

Can I use PostgreSQL advisory locks instead of Redis for distributed coordination?

Yes, you can use PostgreSQL advisory locks for DB-bound distributed coordination. They provide a robust alternative to Redis when your locking requirements are tightly coupled to database transaction boundaries.

What is the best way to handle distributed locking across multiple Redis nodes?

The best way to handle distributed locking across multiple Redis nodes is using the Redlock algorithm. It provides high availability by acquiring locks on multiple independent nodes simultaneously to prevent single-point failures.

What are common failure modes when using TTL-based distributed locks?

Common failure modes for TTL-based distributed locks include process crashes before releasing locks and network partitions causing split-brain scenarios. Mitigations involve using fencing tokens and carefully tuning TTL expiration values.