Skip to content

feat(GALE): Invalidate derived data on merge#118378

Merged
ceorourke merged 5 commits into
masterfrom
ceorourke/invalidate-derived-data
Jun 24, 2026
Merged

feat(GALE): Invalidate derived data on merge#118378
ceorourke merged 5 commits into
masterfrom
ceorourke/invalidate-derived-data

Conversation

@ceorourke

Copy link
Copy Markdown
Member

Experimental option for handling derived data after groups have been merged - hard delete the derived data so that when the next GroupActionLogEntry (GALE) is processed, derived data will replay all of the GALE entries from epoch and regenerate the result to include the merged actions as well (as opposed to continuing from the current cursor and not considering the merged in group's actions).

We may not go with this long term but it's not hooked up to anything yet and is the easiest option to implement.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 24, 2026
@ceorourke ceorourke marked this pull request as ready for review June 24, 2026 20:49
@ceorourke ceorourke requested a review from a team as a code owner June 24, 2026 20:49
@ceorourke ceorourke requested a review from a team June 24, 2026 20:50
Comment thread src/sentry/tasks/merge.py Outdated

@saponifi3d saponifi3d left a comment

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.

just the bot comment and lgtm! excited to see the fun cases this uncovers 🤣

Comment thread src/sentry/tasks/merge.py Outdated
Comment thread src/sentry/tasks/merge.py Outdated
Comment thread src/sentry/tasks/merge.py Outdated
Comment thread src/sentry/tasks/merge.py

@cursor cursor Bot left a comment

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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a997f36. Configure here.

Comment thread src/sentry/tasks/merge.py
Comment thread src/sentry/tasks/merge.py
Comment on lines +212 to +214
"organizations:hard-delete-derived-data-invalidation",
group.project.organization,
):

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.

Bug: A NameError occurs if all groups to be merged are missing, as the group variable is accessed before it is assigned.
Severity: HIGH

Suggested Fix

The group variable should be defined before its use on line 213. One approach is to fetch the to_object_id's group and use it for the feature flag check when the from_object_ids list becomes empty. Alternatively, ensure the logic accessing group is only executed when group is guaranteed to be defined.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/sentry/tasks/merge.py#L212-L214

Potential issue: In the `merge_groups` task, if all group IDs in `from_object_ids` fail
to be found in the database (e.g., due to a race condition where a group is deleted
after the task is queued), the `group` variable will never be assigned. When the
`from_object_ids` list becomes empty, the code proceeds to a final `else` block where it
attempts to access `group.project.organization`. This access will raise a `NameError`
because `group` is unbound, causing the task to crash.

@ceorourke ceorourke merged commit 999d835 into master Jun 24, 2026
85 checks passed
@ceorourke ceorourke deleted the ceorourke/invalidate-derived-data branch June 24, 2026 22:20
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