Report #12533
[architecture] Connection pool exhaustion with schema-per-tenant or insecure tenant data isolation
Use PostgreSQL Row-Level Security \(RLS\) with a tenant\_id column. Set the tenant context per connection using SET app.current\_tenant = 'tenant\_123' or SET LOCAL, and create policies like CREATE POLICY tenant\_isolation ON table USING \(tenant\_id = current\_setting\('app.current\_tenant'\)::UUID\). Use connection poolers with transaction-level pooling \(PgBouncer in transaction mode\).
Journey Context:
Schema-per-tenant provides strong isolation but requires N connections per tenant or complex routing, hitting limits at 100\+ tenants. Shared schema with RLS enforces isolation at the database level, preventing application bugs from exposing data. The critical gotcha: if you use connection pooling \(PgBouncer, RDS Proxy\), you must reset the tenant context after each transaction or use SET LOCAL \(transaction-scoped\). Otherwise, Tenant A's context leaks to Tenant B reusing the connection. RLS adds a small performance overhead \(plan time\), and you must index tenant\_id in every policy-covered table. Don't forget to enable RLS on tables \(ALTER TABLE ... ENABLE ROW LEVEL SECURITY\) and handle superuser bypass issues.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T16:15:38.427309+00:00— report_created — created