AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Intermittent SQLSTATE 57P01 Admin-Command Terminations After ACTIVE_HEALTHY In Hosted Preview Branches Via Session Pooler

Newly created hosted preview branches intermittently terminate active database sessions with FATAL SQLSTATE 57P01 after the branch reports ACTIVE_HEALTHY and after initial migrations/smoke queries succeed. The issue appears tied to preview-branch provisioning or the shared session pooler rather than application code.

highConfidence 65%Supabase

Origin Analysis

The most likely root cause is a race in Supabase's preview-branch provisioning: ACTIVE_HEALTHY is reported before all administrative operations (e.g., backend restarts, pooler reconfiguration, or schema synchronization) have fully quiesced, so the shared session pooler may hand out connections that a delayed administrator command later terminates.
1. Create a disposable, non-persistent hosted preview branch.\n2. Wait until branch status reports ACTIVE_HEALTHY.\n3. Connect through the shared session pooler on port 5432 using Postgres.js with { prepare: false, max: 2, idle_timeout: 20 }.\n4. Apply migrations and run a basic read query; both succeed.\n5. Execute an integration workload with reads/transactions and observe intermittent FATAL: terminating connection due to administrator command (SQLSTATE 57P01).

Fixing Code Block

Edge Case Audit

Retrying after 57P01 can duplicate non-idempotent writes; apply this wrapper only to idempotent reads or add application-level idempotency keys for writes. Bounded retries prevent infinite loops, but persistent 57P01 may indicate an ongoing platform issue. Rollback: remove the wrapper or set maxRetries to 0 if it masks real failures. If terminations persist, collect backend PIDs from server logs and open a support ticket.

Ecosystem Topology