Currently in testing: the GitHub code will be opened once complete.

Protocol (Cluster) — Server ↔ Server

The peer RPC protocol, used only in cluster mode. Nodes share a single lock state via Raft consensus — every lock-state change (acquire, release, expiry) is only applied after the leader's proposal → majority replication → commit, so mutual exclusion holds even during a partition or failover. See How It Works for the conceptual explanation.

Flow — from one acquire to its commit

Client
Leader
Follower 1
Follower 2
A · acquire (key)
AppendEntries (Grant)
AppendEntries (Grant)
OK
majority reached → commit, applied on every node
A · acquired (token)
requestresponseconsensus RPC (Raft)

The leader turns the lock command into a replicated command, carries it in an AppendEntries RPC, and commits once a majority including itself has recorded it (with 3 nodes, the leader plus follower 1 is enough — it doesn't wait for the rest). The client response only goes out after the commit, so once you've received a response, that lock is written into the majority.

Port & Address Rules

  • Peer RPC uses a dedicated Raft port = client port + 1000 (e.g. 52256225). It's derived automatically with no separate config key, and only listens in cluster mode. Your firewall needs to open both ports.
  • Configuration (cluster_self/cluster_peers) always holds the client address. Only the dial to a peer adds +1000 to the port — the M (moved) redirect address handed to clients is always the plain client address.
  • Roles are distinguished purely by port — there's no in-protocol step to tell client and peer apart. See Connection & Auth for the connection order and auth/TLS rules.

Contents

See Also