Project Restore Hangs Without Timeout Due To Missing Lock/Statement Timeout
The reported Supabase project restore remains stuck indefinitely. Given the sparse issue details, the most probable root cause is a restore transaction blocked by long-running queries or lock contention, with no configured timeout or progress tracking.
The restore operation runs a long transaction without setting statement_timeout or lock_timeout, allowing it to wait forever on locks or active connections. The platform's restore worker lacks a circuit breaker or watchdog to detect stuck restores and fail fast.
1. Create a Supabase project.\n2. Trigger a database restore from backup.\n3. Wait for the restore to complete; it remains in 'Restoring' state indefinitely without error.
Fixing Code Block
ALTER DATABASE postgres SET statement_timeout = '5min';
ALTER DATABASE postgres SET lock_timeout = '10s';
-- Kill long-running transactions that may block restore (run with caution)
SELECT pg_terminate_backend(pid)
FROM pg_stat_activity
WHERE datname = current_database()
AND pid <> pg_backend_pid()
AND state = 'active'
AND query_start < now() - interval '10 minutes';
Set database-level statement_timeout and lock_timeout to prevent restore from hanging on locks. The pg_terminate_backend command removes long-running active queries that may hold locks required by restore. This is a temporary mitigation until the restore worker implements a timeout/retry mechanism.
Edge Case Audit
This SQL terminates active queries, potentially disrupting legitimate workloads. It should not be run on production without approval. Ensure backups exist. To rollback, use ALTER DATABASE postgres RESET statement_timeout; ALTER DATABASE postgres RESET lock_timeout; If restore still fails, contact Supabase support.