infra(db-roles): dedicated non-superuser roles for the six superuser apps #3
Loading…
Reference in a new issue
No description provided.
Delete branch "infra/app-db-roles"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Dedicated non-superuser Postgres roles for the six service connections that currently run as the
postgressuperuser — the root of thetoo many connectionspeaks and a standing least-privilege risk.Superuser sessions can consume the
superuser_reserved_connectionsslots and ignore per-role caps, so the 100-slot ceiling can fill with no admin headroom. Each new role gets a hardCONNECTION LIMIT+ bounded timeouts, so the budget becomes bounded and visible.The six connections (confirmed live)
webhook_receiverwebhook_app(write)ingest_workeringest_app(write)workerworker_app(read)dashboard_apibackenddashboard_app(read)gatewaygateway_app(rw)croncron_app(rw)Budget: new 53 + existing readers ~28 ≈ 81 < 100 ✅ (
gateway/cronuse a separate DB but the same server, so they count too).Files
scripts/app_roles_tracksolid_db.sql—ts_app_read/ts_app_writecapability groups + the four login roles, NOSUPERUSER, withCONNECTION LIMITand per-role GUCs (statement_timeout,idle_session_timeout,idle_in_transaction_session_timeout,lock_timeout).scripts/app_roles_fleet_platform.sql—fp_app_rwover the fleet_platform schemas (auth/domain/events/geo/ops/serve/slo/state) +gateway_app/cron_app.scripts/MIGRATE_APPS_OFF_SUPERUSER.md— the runbook: discovery (what each app writes / whether it runs DDL), the connection-budget table, the object-ownership step for migration-running apps (reassign the app schemas to the existingtracksolid_owner— scoped, neverREASSIGN OWNED BY postgresglobally), one-at-a-time cutover order, and instant rollback (revertDATABASE_URLonly).Honest caveats
permission denied.postgres, so these roles can write rows but not run DDL on existing tables. Apps that migrate at deploy need the ownership step (runbook Step 3).Relationship to the other PRs
🤖 Generated with Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.