-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
chore(launchpad): change size analysis upload logic to create/update size metrics table #94656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(launchpad): change size analysis upload logic to create/update size metrics table #94656
Conversation
src/sentry/preprod/tasks.py
Outdated
preprod_artifact.save(update_fields=["analysis_file_id", "state", "date_updated"]) | ||
|
||
# Get or create PreprodArtifactSizeMetrics record | ||
size_metrics, created = PreprodArtifactSizeMetrics.objects.get_or_create( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have an upsert method?
e421c6a
to
ca3696e
Compare
ec930e9
to
221dedf
Compare
011197c
to
fe84025
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Transaction Split Causes Artifact Inconsistency
The code now uses two separate transactions for updating the artifact state and creating/updating size metrics. This breaks atomicity, leading to an inconsistent state where a PreprodArtifact
is marked PROCESSED
but lacks corresponding size metrics if the second transaction fails. This can mislead downstream consumers. Additionally, the assembled file is not cleaned up upon failure of the second transaction, causing a resource leak. The original code maintained atomicity and ensured cleanup via a single transaction.
src/sentry/preprod/tasks.py#L218-L233
sentry/src/sentry/preprod/tasks.py
Lines 218 to 233 in 06637fd
# Update artifact state in its own transaction with proper database routing | |
with transaction.atomic(router.db_for_write(PreprodArtifact)): | |
preprod_artifact.state = PreprodArtifact.ArtifactState.PROCESSED | |
preprod_artifact.save(update_fields=["state", "date_updated"]) | |
# Update size metrics in its own transaction | |
with transaction.atomic(router.db_for_write(PreprodArtifactSizeMetrics)): | |
size_metrics, created = PreprodArtifactSizeMetrics.objects.update_or_create( | |
preprod_artifact=preprod_artifact, | |
defaults={ | |
"analysis_file_id": assemble_result.bundle.id, | |
"metrics_artifact_type": PreprodArtifactSizeMetrics.MetricsArtifactType.MAIN_ARTIFACT, # TODO: parse this from the treemap json | |
"state": PreprodArtifactSizeMetrics.SizeAnalysisState.COMPLETED, | |
}, | |
) |
Was this report helpful? Give feedback by reacting with 👍 or 👎
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
Legal Boilerplate
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.