Skip to content

Conversation

@yuvmen
Copy link
Member

@yuvmen yuvmen commented Nov 11, 2025

We are seeing deletions failing on grouphash deletions on Project.delete(). This suggests delete_project_group_hashses is not deleting all hashes. Refactored this deletion to catch orphan grouphashses that might be left causing this timeout. Utilizes delete_group_hashes by adding a mode for deleting all group hashes of a project.

We are seeing deletions failing on grouphash deletions on `Project.delete()`. This suggests
`delete_project_group_hashses` is not deleting all hashes. Refactored this deletion to catch
orphan grouphashses that might be left causing this timeout. Utilizes `delete_group_hashes` by
adding a mode for deleting all group hashes of a project.
@yuvmen yuvmen requested a review from a team as a code owner November 11, 2025 22:38
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 11, 2025
@codecov
Copy link

codecov bot commented Nov 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #103187      +/-   ##
===========================================
+ Coverage   76.16%    80.64%   +4.47%     
===========================================
  Files        9222      9241      +19     
  Lines      393800    394108     +308     
  Branches    25109     25052      -57     
===========================================
+ Hits       299939    317823   +17884     
+ Misses      93413     75823   -17590     
- Partials      448       462      +14     

Copy link
Member

@armenzg armenzg left a comment

Choose a reason for hiding this comment

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

Discussing this in Slack.

Copy link
Member

@armenzg armenzg left a comment

Choose a reason for hiding this comment

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

Good find!

for group in RangeQuerySetWrapper(
Group.objects.filter(project_id=project_id), step=GROUP_CHUNK_SIZE
):
groups.append(group)
Copy link
Member

Choose a reason for hiding this comment

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

This was basically restricting the deletions to rows with group being set and missing all non-group related rows.

All rows for this project are null:

SELECT count(*) FROM `getsentry.sentry_grouphash` WHERE project_id IN (4506269346365440) and group_id is null;

)[:hashes_batch_size]
hashes_chunk = list(qs)
# Base query: all hashes for this project
qs = GroupHash.objects.filter(project_id=project_id)
Copy link
Member

Choose a reason for hiding this comment

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

This will allow querying for rows w/o having group being set.

)
assert len(events) == 0

def test_delete_orphaned_grouphashes(self) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

This test will fix with or without the fix above since we don't have the 30 second stomping during tests and the ORM deletion of Project will delete everything.

Copy link
Member Author

Choose a reason for hiding this comment

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

oh right, you mean because actually once a project gets fully deleted the orphaned ones would get deleted anyway. I think I will instead convert it to a targeted test for delete_project_group_hashes method

Copy link
Member

Choose a reason for hiding this comment

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

Good idea!

@yuvmen yuvmen merged commit d0ab0ee into master Nov 12, 2025
66 checks passed
@yuvmen yuvmen deleted the yuvmen/fix-scheduled-deletion-fails branch November 12, 2025 23:19
andrewshie-sentry pushed a commit that referenced this pull request Nov 13, 2025
We are seeing deletions failing on grouphash deletions on `Project.delete()`.
This suggests `delete_project_group_hashses` is not deleting all 
hashes. Refactored this deletion to catch orphan grouphashses that 
might be left causing this timeout. Utilizes `delete_group_hashes` by
 adding a mode for deleting all group hashes of a project, renaming it for simplicity.
@sentry
Copy link

sentry bot commented Nov 13, 2025

Issues attributed to commits in this pull request

This pull request was merged and Sentry observed the following issues:

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.

3 participants