Skip to content

feat(GAL): Trigger derived data rebuild after project backfill completes#119783

Merged
yuvmen merged 4 commits into
masterfrom
yuvmen/gal-backfill-trigger-derived-data
Jul 16, 2026
Merged

feat(GAL): Trigger derived data rebuild after project backfill completes#119783
yuvmen merged 4 commits into
masterfrom
yuvmen/gal-backfill-trigger-derived-data

Conversation

@yuvmen

@yuvmen yuvmen commented Jul 15, 2026

Copy link
Copy Markdown
Member

Summary

  • When the project-level GAL backfill chain finishes (no more activities to process), fire process_project_derived_data to rebuild GroupDerivedData for all groups missing it
  • This ensures derived data is up-to-date after a backfill, especially after a reset that deletes all GroupDerivedData rows
  • process_project_derived_data only processes groups without an existing GroupDerivedData row, so it's safe to call unconditionally

Test plan

  • New test test_triggers_derived_data_on_completion verifies the task is called on backfill completion
  • All 28 existing backfill tests pass

When the project-level GAL backfill finishes (no more activities to
process), fire process_project_derived_data to rebuild GroupDerivedData
for all groups that are missing it. This ensures derived data is
up-to-date after a backfill, especially after a reset that deletes
all GroupDerivedData rows.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
@yuvmen yuvmen requested a review from a team as a code owner July 15, 2026 22:19
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 15, 2026

@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 7d45815. Configure here.

Comment thread src/sentry/tasks/backfill_group_action_log.py
The derived data rebuild only fired when the batch query returned
empty. A final partial batch (len < batch_size) would skip both the
self-chain and the rebuild. Add the trigger to the else branch so
backfills that don't end on an exact batch boundary still rebuild.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
@kcons kcons self-requested a review July 15, 2026 22:31
Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
)
activities = list(qs.order_by("datetime", "id")[:batch_size])

from sentry.issues.derived.tasks import process_project_derived_data

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

seems an odd place to import

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.

🤦‍♂️


from sentry.issues.derived.tasks import process_project_derived_data

if not activities:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wish we could say "if we didn't backfill, no generation should be necessary" but we're not that organized yet.

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.

we can actually detect when were on the first batch, because we would have no cursor... ill add a check to cover this case

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

no, currently we don't have a "backfill unnecessary so gdd works without it" state, so backfill functions as our enable step, even though conceptually we should only need regen if we change history.

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.

hmm this would only cover an empty project though, would ahve to thread like the converted count, to remember if we ever converted anything, not sure its worth the additional complexity

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.

no sure I follow exactly, just to be sure we are on the same page - the reprocess I trigger here doesnt redo the GDD, but the reset task deletes it when it starts, so the reset task will cause it all to get created.

Anyway not sure its related to the comment, bottom line - I think I prefer possibly triggering this needlessly than to add some more logic just to remember if we converted an activity somewhere along the chain. And the GDD regeneration only fills in gaps so I think were good

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
@yuvmen yuvmen merged commit ee0b724 into master Jul 16, 2026
64 checks passed
@yuvmen yuvmen deleted the yuvmen/gal-backfill-trigger-derived-data branch July 16, 2026 16:57
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