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
Before-promotion backfill can write to a prod table before schema migration #6267
PlanStagesBuilder.build runs the before-promotion BackfillStage before MigrateSchemasStage. Representative snapshots are placed in that early backfill. On a prod plan the deployability index is then swapped to all_deployable(), so the backfill writes to the production physical table.
If one of those snapshots also requires a schema migration, the table does not yet have columns added by an upstream change. The write can fail. The write can also succeed without the new column values while the intervals are recorded complete. MigrateSchemasStage runs later and does not backfill those intervals again.
When this happens
This stage order already exists. A dev plan sets the migration list to empty, so it does not hit this. A full-mode prod plan already puts representative models in the early backfill, including an unpaused forward-only model and an indirect non-breaking model that has prod intervals.
dev_only adds one more case. A paused indirect non-breaking snapshot with prod intervals is now representative, so a prod plan moves it from the after-migration backfill into the before-migration backfill. That matters only when that same snapshot also requires a schema migration.
Expected
Migrate the target table before any backfill that writes to it, or keep snapshots that require schema migration out of the before-promotion backfill.
Possible Fix
Leave the stage order in place. In PlanStagesBuilder.build, skip snapshots with requires_schema_migration_in_prod when building before_promote_snapshots. after_promote_snapshots is everything selected for backfill minus that set, so those snapshots land in the backfill that already runs after MigrateSchemasStage.
Moving MigrateSchemasStage above the early backfill would also add the columns first. The early backfill is there so representative models can write the shared prod table before promotion, and the restatement stage is deliberately after that backfill. Dropping the migrating snapshots from the early set is the smaller change.
Activity