Skip to content

Locks

A lock is an exclusive named grant on the Raft log. The leader is the only writer. Followers forward.

Behavior
LockBlocks until acquired or the RPC deadline
TryLockOne attempt
Unlockholder + fencing token must match
RenewExtends deadline; ttl_ms = 0 reuses the last TTL
ListLocksAll current grants

Rules

  • Name: 1–128 characters, letters, digits, ., _, -
  • Default TTL 15s, max 24h, min 1ms
  • Max 4096 locks in the table
  • Token is monotonic. Store it with any write that must be fenced

Dead holder: TTL + leader expire scan → lock.expired.

Observers

An observer rejects Lock / TryLock / Unlock / Renew (FailedPrecondition). ListLocks is allowed. See observers.

SDK

The SDK renews in the background (about TTL/3). Close unlocks what this connection holds. Empty holder becomes a generated sdk-<hex> so two apps cannot unlock each other.

Go TryLock when held: (nil, false, nil) — not an error.

Documentation is sourced from the clusdr/docs tree.