Skip to content

Commit 0145f79

Browse files
committed
address feedback: forbid migrating mz_cluster_replica_frontiers
1 parent 523a788 commit 0145f79

3 files changed

Lines changed: 27 additions & 6 deletions

File tree

src/adapter/src/catalog/open/builtin_schema_migration.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ use futures::future::BoxFuture;
3737
use mz_build_info::{BuildInfo, DUMMY_BUILD_INFO};
3838
use mz_catalog::builtin::{
3939
BUILTIN_LOOKUP, Builtin, Fingerprint, MZ_CATALOG_RAW, MZ_CATALOG_RAW_DESCRIPTION,
40-
MZ_OBJECT_ARRANGEMENT_SIZE_HISTORY_DESCRIPTION, MZ_STORAGE_USAGE_BY_SHARD,
41-
MZ_STORAGE_USAGE_BY_SHARD_DESCRIPTION, RUNTIME_ALTERABLE_FINGERPRINT_SENTINEL,
40+
MZ_CLUSTER_REPLICA_FRONTIERS_DESCRIPTION, MZ_OBJECT_ARRANGEMENT_SIZE_HISTORY_DESCRIPTION,
41+
MZ_STORAGE_USAGE_BY_SHARD, MZ_STORAGE_USAGE_BY_SHARD_DESCRIPTION,
42+
RUNTIME_ALTERABLE_FINGERPRINT_SENTINEL,
4243
};
4344
use mz_catalog::config::BuiltinItemMigrationConfig;
4445
use mz_catalog::durable::objects::SystemObjectUniqueIdentifier;
@@ -758,6 +759,15 @@ impl Migration {
758759
"mz_catalog_raw cannot be migrated"
759760
);
760761

762+
// The 0dt caught-up gate reads the leader's `mz_cluster_replica_frontiers` shard for
763+
// the live frontiers it checks every collection against. Migrating it via `Replacement`
764+
// hands us a fresh shard we write ourselves, so the gate would compare us against
765+
// ourselves instead of against the leader.
766+
assert_ne!(
767+
&*MZ_CLUSTER_REPLICA_FRONTIERS_DESCRIPTION, object,
768+
"mz_cluster_replica_frontiers cannot be migrated or else the 0dt caught-up gate loses its live-frontier reference"
769+
);
770+
761771
let Some(object_info) = self.system_objects.get(object) else {
762772
panic!("migration step for non-existent builtin: {object:?}");
763773
};

src/adapter/src/coord/caught_up.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,11 @@ impl Coordinator {
272272
// set. `mz_cluster_replica_frontiers` is a controller-managed builtin
273273
// written with ±1 diffs, so it satisfies that invariant.
274274
//
275-
// NOTE: these are the leader's frontiers only because we read the leader's shard. A
276-
// release that `Replacement`-migrates `mz_cluster_replica_frontiers` itself, or a test
277-
// forcing replacement across all builtins, hands us a shard we write ourselves, and the
278-
// lag check below then compares this deployment against itself.
275+
// NOTE: these are the leader's frontiers only because we read the leader's shard.
276+
// `validate_migration_steps` forbids migrating `mz_cluster_replica_frontiers` for this
277+
// reason, so a declared migration can't reach here. A test forcing replacement across all
278+
// builtins bypasses that guard, hands us a shard we write ourselves, and the lag check
279+
// below then compares this deployment against itself.
279280
let live_frontiers = self
280281
.controller
281282
.storage_collections

src/catalog/src/builtin.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,16 @@ pub static MZ_OBJECT_ARRANGEMENT_SIZE_HISTORY_DESCRIPTION: LazyLock<SystemObject
836836
object_type: CatalogItemType::Table,
837837
object_name: MZ_OBJECT_ARRANGEMENT_SIZE_HISTORY.name.to_string(),
838838
});
839+
840+
/// Identifies [`MZ_CLUSTER_REPLICA_FRONTIERS`] for the schema-migration guard in
841+
/// `builtin_schema_migration.rs`, which forbids migrating this source because the 0dt
842+
/// caught-up gate reads the leader's shard for it to learn the live frontiers.
843+
pub static MZ_CLUSTER_REPLICA_FRONTIERS_DESCRIPTION: LazyLock<SystemObjectDescription> =
844+
LazyLock::new(|| SystemObjectDescription {
845+
schema_name: MZ_CLUSTER_REPLICA_FRONTIERS.schema.to_string(),
846+
object_type: CatalogItemType::Source,
847+
object_name: MZ_CLUSTER_REPLICA_FRONTIERS.name.to_string(),
848+
});
839849
pub const MZ_SYSTEM_ROLE: BuiltinRole = BuiltinRole {
840850
id: MZ_SYSTEM_ROLE_ID,
841851
name: SYSTEM_USER_NAME,

0 commit comments

Comments
 (0)