supabase db reset intermittently fails: temporary Realtime init job races with the running Realtime service on "schema_migrations_pkey"
Maintainer thường phản hồi trong vòng 1 ngày
@7ttp đang làm issue này rồi.
Từ ngày 30/9/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 2.4k
- Fork
- 533
- Merge trung bình
- 21 giờ 49 phút
- Pull request đã merge (30 ngày)
- 371
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của supabase/cli
-
🐛 Bug supabase/cli
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
db schema declarative sync: no way to fail (non-zero exit) when the generated migration is destructiveCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở✨ Feature supabase/cli
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
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 requestCó thể đã có người làm @7ttp đã nhận 13 ngày trước. Đang mở🐛 Bug supabase/cli
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
supabase/cli#6975 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
📘 Docs supabase/cli
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
supabase/cli#6974 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Migration error caret is missing or misplaced when the statement contains multibyte charactersĐang mở🐛 Bug supabase/cli
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
aws/agentcore-cli#2606 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ai-driven-qa bug Cosmetic
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
ai-driven-qa bug claude Minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
linagora/twake-mail-admin#301 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
reproduced
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
anomalyco/opencode#56038 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày