Skip to content

feat(snapshots): Run snapshot comparisons when uploads received out-of-order#112474

Merged
rbro112 merged 2 commits intomasterfrom
ryan/04-08-run_snapshot_comparisons_when_uploads_received_out-of-order
Apr 8, 2026
Merged

feat(snapshots): Run snapshot comparisons when uploads received out-of-order#112474
rbro112 merged 2 commits intomasterfrom
ryan/04-08-run_snapshot_comparisons_when_uploads_received_out-of-order

Conversation

@rbro112
Copy link
Copy Markdown
Member

@rbro112 rbro112 commented Apr 8, 2026

We discovered some cases where base is being uploaded after head. This results in comparisons not being fired for the HEAD snapshots, which ends up as a no base build found error.

This wires up snapshots to be triggered when a base is uploaded and has a head that contains no comparison yet.

Resolves EME-1019

@rbro112 rbro112 requested a review from a team as a code owner April 8, 2026 15:55
Copy link
Copy Markdown
Member Author

rbro112 commented Apr 8, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 8, 2026
@rbro112 rbro112 changed the title Run snapshot comparisons when uploads received out-of-order feat(snapshots): Run snapshot comparisons when uploads received out-of-order Apr 8, 2026
Comment on lines +666 to +682
try:
PreprodSnapshotComparison.objects.get_or_create(
head_snapshot_metrics=head_metrics,
base_snapshot_metrics=snapshot_metrics,
defaults={"state": PreprodSnapshotComparison.State.PENDING},
)
except IntegrityError:
pass

compare_snapshots.apply_async(
kwargs={
"project_id": project.id,
"org_id": project.organization_id,
"head_artifact_id": head_artifact.id,
"base_artifact_id": artifact.id,
},
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: shall we extract this into a helper method since it's a copy pasta of code from line 606?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I personally don't think it cleans things up much and just adds more indeterminism to track down a shared helper, so I'm fine lightly duplicating to avoid redirection

Comment thread src/sentry/preprod/api/endpoints/preprod_artifact_snapshot.py Outdated
commit_comparison__base_sha=base_sha,
commit_comparison__base_repo_name=base_repo_name,
project_id=project_id,
preprodsnapshotmetrics__isnull=False,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

shouldn't we also exclude builds that have size metrics in this query too?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In practice I don't think there will ever be a case where snapshotmetrics and size metrics are both set

@rbro112 rbro112 force-pushed the ryan/04-08-run_snapshot_comparisons_when_uploads_received_out-of-order branch from cf92c2f to d2e185e Compare April 8, 2026 17:07
@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 8, 2026

@rbro112 rbro112 merged commit dc175d1 into master Apr 8, 2026
57 checks passed
@rbro112 rbro112 deleted the ryan/04-08-run_snapshot_comparisons_when_uploads_received_out-of-order branch April 8, 2026 17:31
george-sentry pushed a commit that referenced this pull request Apr 9, 2026
…f-order (#112474)

We discovered some cases where base is being uploaded after head. This
results in comparisons not being fired for the HEAD snapshots, which
ends up as a no base build found error.

This wires up snapshots to be triggered when a base is uploaded and has
a head that contains no comparison yet.

Resolves EME-1019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants