Distributed Locks

Coordinate across owners only when database constraints or partition ownership cannot.

Problem

Multiple processes sometimes need a time-bounded lease over an external resource.

When to use it

  • A real cross-system singleton remains after redesign
  • Fencing tokens protect the resource

When not to use it

  • A unique constraint, row lock, or single partition owner works
  • Correctness relies only on lease expiry

Minimal example

Acquire monotonic fencing token; resource rejects operations with an older token even if a paused holder resumes.

Tradeoffs

  • Leases expire during pauses
  • Without fencing, mutual exclusion can be illusory