Distributed Lock Service  ·  View 14 of 26  ·  5 · Runtime

Acquire, Write, Release — the Uncontended Path

The token is minted by the commit, carried by the holder, and checked where the write lands.

Editable source SVG draw.io All views
Caller workload Client library Lock arbiter etcd leader etcd followers Guarded resource 1. acquire(key, onFence) 2. Acquire · session lease L 3. class · prefix grant · quota 4. Txn: epoch = E, key absent → put on L 5. append entry 6. fsync · majority ack 7. committed · revision R 8. granted · token (E, R) 9. token · remaining TTL 10. UPDATE … WHERE fence < token 11. 1 row · high-water = token 12. release() 13. Release 14. Txn: delete if held on L Acquire, Write, Release — the Uncontended Path One consensus round trip to grant, one to release. Renewal rides the session lease, not the lock. v 1.0 · owner Platform Architecture · date 2026-09

Decisions

  • The grant is one etcd transaction: compare the epoch key and compare the lock key absent, then put the holder key on the caller's session lease. Epoch check, exclusion check and grant commit as one Raft entry.
  • The token is (epoch, revision of that transaction). It is known the moment the commit returns and nothing else has to be written to create it.
  • Release is a transaction that deletes the key only if it is still attached to the caller's lease. A late release from a holder that already lost the lock deletes nothing.

Latency budget, p99 40 ms

  • Envoy and arbiter: under 3 ms including mTLS on a warm connection.
  • Raft commit: leader append, two follower appends and fsyncs across halls, majority ack. Sub-millisecond network, 1 to 5 ms NVMe fsync at the tail.
  • The rest is queueing at 30,000 writes a second of burst. That is where p99 is actually lost, and why the benchmark must be run at burst, not at steady state.

What the resource must do

  • Store the highest token it has accepted per guarded record and reject any write carrying a token less than or equal to it, atomically with the write. A check followed by a separate write is not a fence.