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
adapter: hydrate migrated builtin MVs before 0dt cut-over
Problem:
A builtin schema migration using the `Replacement` mechanism hands the
new deployment a fresh persist shard. Nothing writes that shard while
the deployment is read-only, because `ComputeController::allow_writes`
no-ops in read-only mode, so the MV's write frontier never advances and
the 0dt readiness gate has to drop it and everything downstream of it
from the caught-up check. The deployment then promotes with those
collections unhydrated, and they all hydrate at once at cut-over,
spiking catalog-server CPU and degrading catalog queries.
Solution:
The replacement shard is exclusively owned by this deployment, so the MV
can write it while we are still read-only. Do that, and keep the MV in
the readiness gate, so it hydrates before cut-over instead of at it.
Previously we didn't do this for builtins derived from mz_catalog
because catalog shard frontier was not held. However, as of 26.17 it is,
so gate the behaviour on the version of the old leader.
The behaviour is gated behind the `enable_0dt_hydrate_migrated_builtin_mvs`
feature flag, on by default, a break-glass revert to the prior
exclude-from-gate behaviour without a redeploy.
Testing:
- New environmentd integration test
`test_0dt_migrated_builtin_mv_hydrates_before_promotion` boots a
read-only generation with a forced `replacement` migration and asserts
the migrated builtin MVs `mz_databases` and `mz_clusters` are readable
before it reports `ReadyToPromote`, proving they hydrate before
cut-over rather than at it.
- Extended the `0dt` mzcompose workflow
`builtin-schema-migrations-replacement` to read those MVs from the
read-only generation before promotion, guarding the same invariant
through a real cross-version upgrade.
Copy file name to clipboardExpand all lines: doc/developer/design/20251015_builtin_schema_migration.md
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,7 +58,8 @@ Doing so requires no writes to durable state, and therefore doesn't interfere wi
58
58
59
59
In the subsequent read-only bootstrap phase, the process creates persist read and write handles using the new schema.
60
60
Read handles perform transparent migration of any data updates that flow through them, so dataflow hydration can proceed using the new schema.
61
-
Write handles only require a matching registered shard schema when writing batches, which is something a read-only process doesn't do.
61
+
Write handles only require a matching registered shard schema when writing batches, which a read-only process performing schema evolution doesn't do: the shard is the leader's live one, so it stays read-only until promotion.
62
+
(Shard replacement is different: there the read-only process does write batches, but to a shard it created for itself. See below.)
62
63
63
64
Once the read-only process gets promoted to a leader, and runs the builtin schema migration mechanism again, it this time registers the new schema with the persist shard.
64
65
Doing so fences out any processes that planned to evolve the schema to an earlier version.
@@ -76,6 +77,10 @@ Notably, it ignores any entries at different versions or deploy generations, to
76
77
Depending on the existing migration shard entries, the process either decides to use the existing replacement shard, or to create the replacement shard and write its ID into the migration shard, at the current version.
77
78
It sets the new shard ID as the migrated collection's shard in its in-memory catalog and commences bootstrapping using the replacement shard.
78
79
80
+
Because this environment exclusively owns the replacement shard, the read-only process force-writes it during bootstrap rather than leaving it read-only until promotion.
81
+
This lets a migrated builtin materialized view and its dependents hydrate before cut-over instead of all at once at cut-over.
82
+
It is safe only for the self-owned replacement shard, never a shard the leader is still serving, which is why it applies to shard replacement and not schema evolution.
83
+
79
84
A leader process performing shard replacement performs the same steps as in read-only mode.
80
85
Additionally, it cleans up durable state written by earlier versions and/or deploy generations by:
81
86
- arranging for the previous shards used by the migrated storage collections to be finalized
0 commit comments