supabase db reset intermittently fails: temporary Realtime init job races with the running Realtime service on "schema_migrations_pkey"
Los mantenedores suelen responder en 1 día
@7ttp ya está trabajando en esto.
Desde el 30/9/2026.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
CLI version: 2.118.0 (Linux, Docker Engine, self-hosted GitHub Actions runner), Postgres 17 local stack.
Describe the bug
supabase db reset (local) fails intermittently at the "Initialising schema" stage with error running container: exit 1. It happens mostly on the second reset of a CI job, when the stack has been running for a while. With --debug, the output of the temporary Realtime init container shows:
Resetting local database...
Recreating database...
Initialising schema...
+ echo 'Running migrations'
+ sudo -E -u nobody /app/bin/migrate
** (Ecto.ConstraintError) constraint error when attempting to insert struct:
* "schema_migrations_pkey" (unique_constraint)
...
(ecto_sql 3.14.0) lib/ecto/migrator.ex:337: anonymous fn/6 in Ecto.Migrator.async_migrate_maybe_in_transaction/7
error running container: exit 1
Why it happens (reading internal/db/reset/reset.go and internal/db/start/start.go at v2.118.0)
resetDatabase15:
- removes and recreates the db container and volume;
- runs
SetupLocalDatabase→initSchema15, which runs one-off containers for Realtime (/app/bin/migrate, seeds,health_check), Storage (migrate-call.js) and GoTrue (gotrue migrate); - only then calls
restartServices(storage, gotrue, realtime, pooler).
During step 2, the persistent supabase_realtime_<project> container is still running against the freshly recreated database. When it restarts itself (it loses its DB connection while the db container is recreated), its entrypoint runs the same Realtime migrations concurrently with the one-off init job. Both insert the same version into _realtime.schema_migrations, and the one-off job crashes on schema_migrations_pkey.
Workaround
Stop the persistent Realtime container before supabase db reset (docker stop supabase_realtime_<project>). restartServices starts it again at the end.
Suggested fix
In resetDatabase15, stop the service containers that run their own migrations (at least Realtime; probably Storage and GoTrue too) before recreating the database, and start them again in restartServices. Alternatively, run the one-off init jobs only while those services are stopped.
To reproduce
supabase startwith Realtime enabled (default config).- Run
supabase db reset --debugand, as soon as it printsInitialising schema..., rundocker restart supabase_realtime_<project>. This simulates the service restarting on its own after losing the database. - The reset fails with the error above. The same sequence with the Realtime container stopped beforehand succeeds.
Observed locally (CLI 2.118.0, 2026-09-30):
- Realtime running and restarted at
Initialising schema...: 1 of 3 resets failed with the exact error above; the one-off Realtime container was the only one that exited 1. - Realtime stopped before the reset: 3 of 3 succeeded, and
restartServicesleft it running. - Plain resets (control): 2 of 2 succeeded.
- Lenguaje dominante
- TypeScript
- Estrellas
- 2.4k
- Forks
- 533
- Merge medio
- 1 d 5 h
- PR fusionados (30 d)
- 338
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de supabase/cli
-
🐛 Bug supabase/cli
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
db schema declarative sync: no way to fail (non-zero exit) when the generated migration is destructiveQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto✨ Feature supabase/cli
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
stack: the HTTP gateway closes idle keep-alive connections after 5 s, so a client whose event loop is blocked gets ECONNRESET (`fetch failed`) on its next requestPosiblemente ocupada @7ttp la tomó hace 10 días. Abierto🐛 Bug supabase/cli
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
supabase/cli#6975 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
📘 Docs supabase/cli
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
supabase/cli#6974 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Migration error caret is missing or misplaced when the statement contains multibyte charactersAbierto🐛 Bug supabase/cli
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
Todos los issues de supabase/cli
Issues similares
-
documentation good first issue hacktoberfest help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
libredb/libredb-studio#1756 ·
Los mantenedores suelen responder en 1 día
-
state:triage-needed
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
lingdojo/kana-dojo#32365 · 1 comentario · 5 reacciones ·
Los mantenedores suelen responder en 1 día
-
friction
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
kentcdodds/kody#3706 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
copperheadhq/copperhead#378 ·
Los mantenedores suelen responder en 1 día