@@ -656,6 +656,34 @@ struct Migration {
656656 config : BuiltinItemMigrationConfig ,
657657}
658658
659+ /// Whether `builtin` participates in a forced migration using `mechanism`.
660+ fn participates_in_forced_migration (
661+ builtin : & Builtin < NameReference > ,
662+ mechanism : Mechanism ,
663+ ) -> bool {
664+ use Builtin :: * ;
665+ match builtin {
666+ // A forced replacement allocates a fresh shard, which discards the
667+ // table's contents. Exclude the tables whose contents are the point:
668+ // storage usage is retained for billing, and hydration history cannot
669+ // be rebuilt from any other source.
670+ //
671+ // Hydration history takes part in a forced `Evolution`, which keeps the
672+ // rows. It has to: dev upgrades force one for every object, and a table
673+ // left out of the plan never gets its new schema registered, so
674+ // `update_fingerprints` panics at open as soon as the desc changes. See
675+ // the tripwire in `validate_migration_steps` for how to give up the
676+ // replacement exemption deliberately.
677+ Table ( table) => {
678+ * * table != * MZ_STORAGE_USAGE_BY_SHARD
679+ && ( mechanism != Mechanism :: Replacement || * * table != * MZ_OBJECT_HYDRATION_HISTORY )
680+ }
681+ MaterializedView ( ..) => true ,
682+ Source ( source) => * * source != * MZ_CATALOG_RAW ,
683+ Log ( ..) | View ( ..) | Type ( ..) | Func ( ..) | Index ( ..) | Connection ( ..) => false ,
684+ }
685+ }
686+
659687impl Migration {
660688 async fn run ( self , steps : & [ MigrationStep ] ) -> anyhow:: Result < MigrationRunResult > {
661689 info ! (
@@ -831,33 +859,7 @@ impl Migration {
831859 // added in this version; the leader will allocate their shards during bootstrap, and
832860 // there is nothing to evolve or replace.
833861 . filter ( |( _, info) | info. shard_id . is_some ( ) )
834- . filter ( |( _, info) | {
835- use Builtin :: * ;
836- match info. builtin {
837- // A forced replacement allocates a fresh shard, which
838- // discards the table's contents. Exclude the tables whose
839- // contents are the point: storage usage is retained for
840- // billing, and hydration history cannot be rebuilt from any
841- // other source.
842- //
843- // The hydration history takes part in a forced `Evolution`,
844- // which keeps the rows. It has to: dev upgrades force one for
845- // every object, and a table left out of the plan never gets
846- // its new schema registered, so `update_fingerprints` panics
847- // at open as soon as the desc changes. The exemption is best
848- // effort, not a guarantee. See the tripwire in
849- // `validate_migration_steps` for how to give it up
850- // deliberately.
851- Table ( table) => {
852- * * table != * MZ_STORAGE_USAGE_BY_SHARD
853- && ( mechanism != Mechanism :: Replacement
854- || * * table != * MZ_OBJECT_HYDRATION_HISTORY )
855- }
856- MaterializedView ( ..) => true ,
857- Source ( source) => * * source != * MZ_CATALOG_RAW ,
858- Log ( ..) | View ( ..) | Type ( ..) | Func ( ..) | Index ( ..) | Connection ( ..) => false ,
859- }
860- } )
862+ . filter ( |( _, info) | participates_in_forced_migration ( info. builtin , mechanism) )
861863 . map ( |( object, _) | object. clone ( ) )
862864 . collect ( ) ;
863865
0 commit comments