supabase db reset intermittently fails: temporary Realtime init job races with the running Realtime service on "schema_migrations_pkey"
メンテナーはふだん 1 日以内に返信
@7ttp がすでに取り組んでいます。
2026年9月30日 から。
評価
この issue はまだ評価されていません。
説明
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.
- 主要言語
- TypeScript
- スター
- 2.4k
- フォーク
- 531
- 平均マージ
- 1日 3時間
- マージ済み PR(30日)
- 332
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
supabase/cli のほかの issue
-
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 request対応中かも @7ttp が 3 日前に担当しました。 オープン🐛 Bug supabase/cli
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
📘 Docs supabase/cli
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
🐛 Bug supabase/cli
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
🐛 Bug supabase/cli
難易度 3/5 半日 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
stack: functions serve fails with "Dependent … blocks restart of …" after a plain supabase startオープン🐛 Bug supabase/cli
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
triage
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
github/docs#46222 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
agent-ready area: config area: skills type: chore upstream: brain-kit
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
-
enhancement priority:low ready-for-dev
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
bug escritorio mapa
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
marcosferr/reporte-ciudadano#4 · コメント 1 件 ·
-
area: material/sort gemini-triaged needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
angular/components#33933 ·
メンテナーはふだん 1 日以内に返信