You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
db schema declarative sync: overlap the two shadow provisions and take shadow teardown off the critical path #7563
On a declarative tree of about 750 SQL files, supabase db schema declarative sync spends most of its wall time outside the diff. We measured these phases from the CLI's trace output (SUPABASE_TRACE_FILE) on CLI 3.1.0, on Linux with Docker, across repeated runs:
Phase
Measured range
First shadow start
2.4–3.5 s
Migration replay in the shadow
3.8–5.2 s
Second shadow start and load
4.1–5.1 s
pg-delta plan
16.8–17.3 s
Shutdown of both shadows, after the diff result is known
3.8–25 s
We did not attribute the shutdown range to a specific teardown path.
Proposed solution
When the two shadows use the sequential strategy, start the second shadow while the first one replays. Keep each shadow's output buffered, as the code already does, so the output stays readable.
Tear the shadows down concurrently, or after the migration file has been written, so teardown does not delay the command's result.
Alternatives considered
--no-cache skips the shadow baseline cache but keeps the sequential provisioning and the teardown, so it does not address the wall time.
Additional context
Source at tag v3.1.0 (commit d4fc0e5):
Strategy selection: apps/cli/src/commands/db/shared/pgdelta-next-shadow.plan.ts, lines 19–32. parallel is chosen only when both shadows are warm, baseline-handoff only when both are cold with the same key, and sequential otherwise. The runner is at lines 40–68.
The comment on the sequential path says the mode keeps the cold side's baseline output off the live stream. The same file contains the output buffering (bufferedShadowOutput).
Release: apps/cli/src/command-internal/db-bootstrap/shadow-database.ts, lines 255–275, runs docker rm -f -v. The cold cache-export path runs docker stop on the shadow container before it writes the baseline archive (apps/cli/src/command-internal/db-bootstrap/shadow-cache.ts, line 620).
Activity