You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(deletions): Delete seer matched group hash metadata first (#102612)
When deleting a GroupHash row, all GroupHashMetadata rows pointing to it
via `seer_matched_grouphash` need updating (see code):
https://github.com/getsentry/sentry/blob/698262018e6009759d8562e2da63be749df7c32d/src/sentry/models/grouphashmetadata.py#L115-L118
Before #101720, we would only delete GroupHash rows and that would time
out because we would stomp queries longer than 30 seconds. In #101720 we
added the deletion of the GroupHashMetadata rows but we should have also
added the updating.
The new code will have these three stages:
```
GroupHashMetadata.objects.filter(seer_matched_grouphash_id__in=hash_ids).update(seer_matched_grouphash=None)
GroupHashMetadata.objects.filter(grouphash_id__in=hash_ids).delete()
GroupHash.objects.filter(id__in=hash_ids).delete()
```
Fixes [SENTRY-5ABJ](https://sentry.sentry.io/issues/6930113529/).
For posterity, this is the top of the stack trace:
```
OperationalError
canceling statement due to user request
SQL: UPDATE "sentry_grouphashmetadata" SET "seer_matched_grouphash_id" = NULL WHERE "sentry_grouphashmetadata"."seer_matched_grouphash_id" IN (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
```
0 commit comments