Skip to content

Bug 2035204 - Prevent creation of duplicate AlertSummary rows for the same push - #9754

Open
junngo wants to merge 1 commit into
mozilla:masterfrom
junngo:prevent-dup-alert-summary
Open

Bug 2035204 - Prevent creation of duplicate AlertSummary rows for the same push#9754
junngo wants to merge 1 commit into
mozilla:masterfrom
junngo:prevent-dup-alert-summary

Conversation

@junngo

@junngo junngo commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=2035204

This PR prevents duplicate AlertSummary rows from being created for the same push.
When a new alert is merged into an existing AlertSummary, prev_push_id is widened to the earliest prev_push seen across the merged alerts, but never narrowed. This is because prev_push_id drives the PerfCompare link, so narrowing it could risk breaking existing references. Manually created summaries (with a sheriff-set prev_push) are left untouched.
Happy to hear any thoughts or concerns on this approach.

@netlify

netlify Bot commented Aug 4, 2026

Copy link
Copy Markdown

Deploy Preview for treeherder ready!

Name Link
🔨 Latest commit 349fd77
🔍 Latest deploy log https://app.netlify.com/projects/treeherder/deploys/6a7445b0cf20e2000899bd55
😎 Deploy Preview https://deploy-preview-9754--treeherder.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

_generate_performance_data(test_repository, signature, base_time, 1, 0.5, before)
_generate_performance_data(
test_repository, signature, base_time, int(interval / 2) + 1, 1.0, int(interval / 2)
)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Example: when gap=True

t:      1    2   ...  13   14  |  15       |  16   17  ...  30
value: 0.5  0.5  ... 0.5  0.5  | (missing) | 1.0  1.0  ... 1.0
                                  ↑
                          no PerformanceDatum exists for t=15

Comment thread treeherder/perf/alerts.py
sheriffed=not signature.monitor,
)
.order_by("created", "id")
.first()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The lead columns for the index are repository and framework, so those are still index-scoped; push and sheriffed are filtered after that. Total AlertSummary row count is about 5,300, so this shouldn't be a performance concern for now.

Comment thread treeherder/perf/alerts.py
existing_prev_timestamp = time.mktime(summary.prev_push.time.timetuple())
if prev.push_timestamp < existing_prev_timestamp:
summary.prev_push_id = prev.push_id
summary.save(update_fields=["prev_push_id"])

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I chose the widened prev_push over the narrower one. Narrowing favors the comparison for the alert that was just merged, while widening avoids losing comparison range for any of the merged alerts. This felt like a policy call, so happy to hear your opinion.

@junngo
junngo force-pushed the prevent-dup-alert-summary branch from 918fbcb to 349fd77 Compare August 6, 2026 08:28
Comment thread treeherder/perf/alerts.py
Comment on lines +202 to +209
PerformanceAlertSummary.objects.filter(
repository=signature.repository,
framework=signature.framework,
push_id=cur.push_id,
sheriffed=not signature.monitor,
)
.order_by("created", "id")
.first()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Add select_related so prev_push is fetched in the same query

Suggested change
PerformanceAlertSummary.objects.filter(
repository=signature.repository,
framework=signature.framework,
push_id=cur.push_id,
sheriffed=not signature.monitor,
)
.order_by("created", "id")
.first()
PerformanceAlertSummary.objects.select_related("prev_push")
.filter(
repository=signature.repository,
framework=signature.framework,
push_id=cur.push_id,
sheriffed=not signature.monitor,
)
.order_by("created", "id")
.first()

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.

2 participants