How to confirm whether timed-out Supabase Management API migrations can still execute? #52502
Replies: 5 comments
|
Postgres has no queue. The migration endpoint runs your SQL on a live session, and that statement is either running right now or it has finished, committed or rolled back. Nothing can start later on its own, and the 35 to 45 second timeout you saw only cut your HTTP connection to the API; it does not by itself cancel the statement the API had already handed to Postgres. So two reads settle it. First, in the SQL editor: select pid, state, xact_start, query_start, left(query, 120) as query
from pg_stat_activity
where datname = current_database()
and pid <> pg_backend_pid()
and state <> 'idle';No row with your migration SQL means nothing is executing and nothing is pending. Second, whether anything committed: Recovery is to run the same guarded SQL again, through the same endpoint or through the SQL editor, which also runs it as one transaction. Keep the guards ( |
|
@Sagargupta16's 1. Terminal status. There isn't one to fetch. In the OpenAPI spec, 2. Can it run after the client gives up? Supabase doesn't document what happens after a client disconnects. Two things are documented:
So a timeout tells you nothing about the outcome. Only the end state does. 3. Proving nothing is pending. Inside Postgres, uncommitted work exists only in a live backend or in a prepared transaction. select pid, usename, application_name, state, xact_start, left(query, 200) as query
from pg_stat_activity
where query ilike '%<your receipt table>%'
or application_name = 'mgmt-api'
or xact_start < now() - interval '10 minutes';
select * from pg_prepared_xacts; -- expect no rows
If both queries come back empty and there's no history row and no objects, nothing from those two requests can still commit inside the database. What you can't see is whether Supabase's API layer would ever start an old request again. Nothing in the spec or docs describes a queue or retry for this endpoint, but only Supabase can rule one out, so that's the exact question to put on your tickets. You don't need the answer to proceed safely (see 4). Logs would have been the other witness. Supabase sets select timestamp, log_attributes['parsed.sql_state_code'] as sqlstate, event_message
from logs
where source = 'postgres_logs'
and event_message ilike '%<your receipt table>%'
order by timestamp
limit 100;Free keeps API and Database logs for 1 day (pricing), though, so the 15:00 and 15:32 UTC windows on the 28th have aged out by now. An empty result there proves nothing. Run that query right after any future attempt. 4. Recovery. Either route is fine once step 3 comes back clean. The SQL is what makes it safe, not the route:
I'd do it by hand. Use the SQL Editor if the migration finishes well inside the dashboard's 60 s query limit. Otherwise use psql over the session pooler, which works over IPv4 on Free (docs): begin;
set local lock_timeout = '5s'; -- fail fast instead of queueing behind a lock
do $$ begin
if to_regclass('public.<receipt_table>') is not null then
raise exception 'migration already applied';
end if;
end $$;
-- reviewed migration statements
insert into supabase_migrations.schema_migrations (version, name, statements)
values (to_char(current_timestamp, 'YYYYMMDDHH24MISS'), '<name>', array[$m$<migration sql>$m$]);
commit;
If you'd rather stay on the API:
|
|
A few things you can establish yourself, plus a way to make the retry safe whatever happened to the earlier requests. Your client timeout says nothing about the server side. The API docs give Read-only check for anything still running or idle in a transaction: select pid, state, xact_start, left(query, 120)
from pg_stat_activity
where backend_type = 'client backend' and pid <> pg_backend_pid()
order by xact_start nulls last;plus You can't prove from outside that nothing is queued, so make a second run harmless. First statements inside the transaction: select pg_advisory_xact_lock(724001); -- any fixed bigint
do $ begin
if to_regclass('app.migration_receipt') is not null then
raise exception 'migration already applied';
end if;
end $;A concurrent run waits on the lock, then aborts on the guard once the first commits. With the guard, retrying through the same endpoint is reasonable and keeps history consistent. |
|
I would be careful about treating an empty It shows what was visible at the time of that database inspection, but it does not establish the provider's retry or request-queue behavior. Before retrying the production migration, I would collect the original request timestamps and identifiers, inspect the migration-history records and expected schema changes, and ask support to confirm the terminal status of the earlier requests. If a retry becomes necessary, use a reviewed migration with explicit preconditions, idempotent operations where possible, and a tested recovery procedure. The key distinction is between proving the current database state and proving the terminal lifecycle of an earlier API request. Both matter for a safe recovery. |
|
Based on the documented Supabase migration workflow, I would be cautious about treating a client-side timeout as proof that a migration was cancelled. A few points that may help:
One important distinction: Could Supabase Support confirm whether either timed-out request is still present in the Management API execution queue, and whether the requests reached PostgreSQL? That server-side confirmation seems essential before safely retrying a production migration. Thanks! |
Uh oh!
There was an error while loading. Please reload this page.
I'm working on a production Supabase application and need guidance before attempting another database migration.
On 28 October 2026, two migration requests submitted through the Supabase Management API did not return a completion response:
Subsequent read-only checks found:
However, these observations do not prove whether the requests were cancelled, rolled back, rejected or remain queued.
My questions:
The migration uses guarded, transactional PostgreSQL SQL. I do not want to retry blindly, weaken security permissions or risk duplicate production changes.
I have contacted Supabase support under tickets SU-530147 and SU-530388, but have not yet received technical execution diagnostics.
I'm looking for a safe approach that works on the Free plan without modifying customer records.
Thank you.
All reactions