Skip to content

Commit cdc4e95

Browse files
committed
docs(controlplane): note why PostgresLock instead of NATS for coordination
NATS is optional infrastructure; Postgres is the only piece every control-plane deployment has. Advisory locks let us coordinate background jobs across replicas without adding a new dependency. Assisted-by: Claude Code Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev> Chainloop-Trace-Sessions: 052e8b56-72b5-4c6c-8d82-ab2d00728889
1 parent 58c3867 commit cdc4e95

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

app/controlplane/pkg/data/lock.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ const advisoryUnlockTimeout = 5 * time.Second
3434
// PostgresLock implements biz.DistributedLock using Postgres session-level
3535
// advisory locks (pg_try_advisory_lock / pg_advisory_unlock).
3636
//
37+
// Postgres is the only piece of infrastructure that's mandatory for the
38+
// control plane — NATS is optional (used for distributed caches when
39+
// present). Using advisory locks lets us coordinate background jobs
40+
// across replicas without adding a new dependency (a NATS KV lease or a
41+
// dedicated queue) that wouldn't be available in every deployment.
42+
//
3743
// Each lock holds a dedicated connection for its lifetime; releasing the
3844
// lock returns the connection to the pool. If the pod crashes mid-run the
3945
// connection drops and Postgres releases the lock automatically.

0 commit comments

Comments
 (0)