NOTIFY.
In embedded mode there is no separate service. The product runs the same
package and holds the snapshot itself. See
Deployment for choosing a mode.
The snapshot
Each replica loads a full snapshot when it starts and evaluates against it. The snapshot holds kinds, roles, bindings, subjects and group membership, and checks never touch the database. Subjects and memberships set a tenant’s size, not bindings. A tenant with 20,000 users in 100,000 group memberships takes roughly 10 to 20 MB. The snapshot interns ids as integers and shares kinds and built-in roles across tenants. Each replica exports its snapshot size per tenant, and the chart setsGOMEMLIMIT. A standalone instance that serves many large tenants
should be split across instances. In embedded mode the snapshot lives in each
product replica.
The access revision
- Each tenant has one counter that only goes up. It is incremented in the same transaction as any write that can change a decision, which covers roles, bindings, groups, group membership and subject activation. Saving a just-in-time subject does not bump it, and neither does a write that changes nothing. Domains and kinds, which every tenant shares, bump a separate instance revision.
NOTIFYcarries the tenant and its new revision, or the instance and its new revision, and is only a hint. The replica reads the revision again and does nothing if it has not moved. Reloads run one at a time, and one that an earlier reload already satisfied is skipped. Each replica listens on one connection of its own, outside its pool. A connection pooler in transaction mode does not deliver notifications, so a replica behind one relies on its poll, which runs every 5 seconds.- Every decision returns both of the snapshot’s revisions, the tenant’s and the instance’s. Management writes return the new revision of whichever counter they bumped.
- Callers may cache a decision for a short time, keyed by tenant and inputs. When a response carries a newer revision for a tenant, the caller drops that tenant’s older entries. Kind changes reach SDK caches within their time to live.
- A caller that needs to read its own writes passes the revision its write
returned. The admin UI after a grant passes
min_revision, and a product checking right after registering a new kind passesmin_instance_revision. The two are separate counters, so a high tenant revision never stands in for a missing kind change. A replica that is behind reads the revisions at once rather than waiting forNOTIFY. A write’s revision is committed before its caller learns it, so if that read does not reach it the check denies withREVISION_TIMEOUTat once. Only a failed read is retried, backing off, for up to 2 seconds. If no read succeeds the check answersUNAVAILABLE, because the answer is unknown rather than a deny. - A replica that cannot confirm a tenant’s revision against Postgres for 5
minutes, which
LATCHKEY_MAX_STALENESSconfigures, answersUNAVAILABLEfor that tenant. Callers treat that as a deny, so a replica cut off from the database cannot keep serving revoked access. Each tenant is confirmed on its own, so one tenant that fails to load does not stop the others.