Skip to content

Feat(state_sync): Add the ability to fetch all versions of a snapshot by name#5273

Merged
erindru merged 4 commits intomainfrom
erin/state-sync-snapshots-by-name
Sep 8, 2025
Merged

Feat(state_sync): Add the ability to fetch all versions of a snapshot by name#5273
erindru merged 4 commits intomainfrom
erin/state-sync-snapshots-by-name

Conversation

@erindru
Copy link
Collaborator

@erindru erindru commented Sep 1, 2025

This is the first in a series of PR's looking at adjusting and clarifying how restatements work.

Currently, when a model is restated in prod, the following occurs:

  1. Intervals are cleared from state for that model
  2. Intervals are cleared from state for all versions of that model present in dev environments

The purpose of that last step is to prevent stale / old data from getting promoted to prod if someone decides to deploy a dev environment containing a version of the model that got built before the prod restatement occurred.

However, the current implementation has a gap. It only clears intervals for snapshots that are promoted in dev environments, because it's limited by what StateSync methods are available and it currently iterates over all environments from StateSync.get_environments_summary().

What about snapshots that arent currently promoted in any environment? There is still a risk that someone makes a change in dev that matches one of these snapshots, and it becomes promoted in dev, and then gets deployed to prod.

So, this PR adds a method to StateSync that allows fetching all versions of a snapshot (based on name) regardless of if it's currently being used in an environment or not.

This will allow the prod restatement "clear intervals" code to properly clear all relevant intervals across all snapshots of the model, rather than skipping intervals for snapshots that don't currently belong to any environment like it does today.

@erindru erindru force-pushed the erin/state-sync-snapshots-by-name branch from b82036f to 42a113c Compare September 5, 2025 04:15
identifier=identifier,
version=version,
dev_version=dev_version,
fingerprint=SnapshotFingerprint.parse_raw(fingerprint),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can still be too much parsing. Can we parse it lazily instead? Similar to how we do this with snapshots in the Environment model.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did wonder about that. I've updated it to be lazily parsed on first access, although it still needs to be provided in string form to construct the object to begin with

@erindru erindru force-pushed the erin/state-sync-snapshots-by-name branch 2 times, most recently from 6040d43 to 48d45aa Compare September 7, 2025 21:10
@erindru erindru force-pushed the erin/state-sync-snapshots-by-name branch from 48d45aa to f234322 Compare September 8, 2025 00:49
@erindru erindru merged commit a6b3298 into main Sep 8, 2025
36 checks passed
@erindru erindru deleted the erin/state-sync-snapshots-by-name branch September 8, 2025 01:36
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.

3 participants