PostgreSQL RLS Multi-tenancy Pattern Non-negotiables - RLS context is mandatory for any tenant-scoped query - Context must be set inside the same transaction as the queries - No fallbacks for tenant ID (fail fast if missing) - Async-only DB access when using async frameworks Setting RLS Context RLS works only if the current transaction has the context set: Must run before the first tenant-scoped query in that transaction. Common Failure Modes - Setting after the first - Setting the context in one session, then querying in another - Running queries outside the expected transaction scope Typica…