fix(migrations): keep still-live dev intervals in v0071#5899
Open
anxkhn wants to merge 1 commit into
Open
Conversation
The v0071 intervals migration compared a bare dev version string against `used_dev_versions`, which only ever holds `(name, dev_version)` tuples. A string is never an element of a set of 2-tuples, so `dev_version not in used_dev_versions` was always true and the guard collapsed to `if is_dev: continue`. Every dev interval whose version was still live (it had already passed the `used_versions` check) was dropped on upgrade, forcing a re-backfill of dev environments. Compare the correctly-typed `(name, dev_version)` key so only genuinely unused dev intervals are removed. Add a regression test that runs the migration against an in-memory DuckDB state with a still-live dev interval and asserts it survives. Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
But the guard that decides whether to drop a dev interval compares a bare
dev_versionstring against that set:A
stris never an element of a set of 2-tuples, sodev_version not in used_dev_versionsis alwaysTrueand the condition collapses toif is_dev: continue. Every dev interval that had already passed the precedingused_versionscheck (i.e. is still live) is discarded, forcing a re-backfill ofdev environments after the upgrade.
This changes the check to compare the correctly-typed
(name, dev_version)key,matching the tuples stored in
used_dev_versions, so only genuinely unused devintervals are removed.
Test Plan
test_migrate_v0071_keeps_still_live_dev_intervalsintests/core/state_sync/test_state_sync.py. It builds an in-memory DuckDB stateat schema v70 (intervals table without the
dev_versioncolumn) with a liveprod snapshot/interval and a live dev snapshot/interval, runs the v0071
migrate_schemas+migrate_rows, and asserts both intervals survive.{'prod_int'} != {'dev_int', 'prod_int'}) and passes with it.to a live snapshot) is still correctly removed, so the fix is not over-broad.
make style(ruff + ruff-format + mypy) passes on the changed files; thetests/core/state_sync/test_state_sync.pymigration/interval subset passes.Checklist
make styleand fixed any issuesmake fast-test)git commit -s) per the DCO