Skip to content

Fix no-gaps plans when production advances before promotion - #5947

Draft
mday-io wants to merge 1 commit into
SQLMesh:mainfrom
mday-io:mday/fix-plan-promotion-interval-frontier
Draft

Fix no-gaps plans when production advances before promotion#5947
mday-io wants to merge 1 commit into
SQLMesh:mainfrom
mday-io:mday/fix-plan-promotion-interval-frontier

Conversation

@mday-io

@mday-io mday-io commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • recompute no-gaps missing intervals against the live production frontier immediately before promotion
  • backfill newly required intervals using the existing plan evaluator and deployability context
  • retain the transactional promotion-time no_gaps check as the final concurrency guard
  • add a deterministic stale-plan/live-frontier regression test

Root cause

A plan freezes its interval horizon when it is constructed. If the existing production snapshot advances before that plan reaches promotion, the candidate can finish every originally scheduled batch yet still be behind the live production frontier. Promotion then correctly rejects the candidate for missing intervals.

The new catch-up stage refreshes candidate intervals and schedules the additional live-frontier gaps immediately before promotion. If production advances again after that read, the existing transactional guard still fails safely.

Validation

  • regression test confirmed to fail at the original no-gaps promotion check with the catch-up handler disabled
  • make fast-test — 2,603 fast tests, 0 failures, 4 skipped; isolated suites also passed
  • pytest tests/core/test_plan_evaluator.py -q — 2 passed
  • focused plan-stage/no-gaps/state-sync suites — passed
  • Ruff, Ruff format, migration validation, and git diff --check upstream/main — passed
  • make style reaches only the local missing generated sqlmesh._version mypy errors; no changed-file type errors
  • independent compatibility review verdict GO

Residual race behavior

Production can still advance in the small window after catch-up. In that case, the retained promotion guard rejects the plan rather than allowing a gap.

Signed-off-by: mday-io <mdaytn@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant