-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
ref(deletions): Remove unnecessary Seer calls in endpoint #93541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| create_audit_entries(request, project, group_list, delete_type, transaction_id) | ||
|
|
||
| # Tell seer to delete grouping records for these groups | ||
| call_delete_seer_grouping_records_by_hash(error_ids) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already part of delete_bulk:
sentry/src/sentry/deletions/defaults/group.py
Lines 275 to 276 in 29dc6ac
| # Tell seer to delete grouping records with these group hashes | |
| call_delete_seer_grouping_records_by_hash(error_group_ids) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this call to seer fails then the task is not get scheduled.
This is one of the main reasons we have so many groups in a pending deletion state.
Redash query: https://redash.getsentry.net/queries/9170/source
|
|
||
| # Removing GroupHash rows prevents new events from associating to the groups | ||
| # we just deleted. | ||
| GroupHash.objects.filter(project_id=project.id, group__id__in=group_ids).delete() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of the models that are deleted.
| models.GroupHash, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this allow new events to be added to the existing issues until the delete is processed? Is that going to do what customers want still?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markstory The group is already marked as pending deletion, thus, the customer can't even see the group.
See lines 67-69:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to keep the group hash until the Seer task gets scheduled, thus, even the more reason to do it during the Group deletion task.
| except InvalidGroupTypeError: | ||
| pass | ||
| # Tell seer to delete grouping records with these group hashes | ||
| call_delete_seer_grouping_records_by_hash(error_group_ids) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving the call under _delete_children.
| try: | ||
| call_delete_seer_grouping_records_by_hash([group.id for group in error_groups]) | ||
| except Exception: | ||
| logger.exception("Error calling seer delete grouping records by hash") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have seen the call fail as part of the API deletion calls, thus, I want to put this guard against it.
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #93541 +/- ##
==========================================
- Coverage 87.83% 87.81% -0.02%
==========================================
Files 10478 10492 +14
Lines 605960 606303 +343
Branches 23674 23674
==========================================
+ Hits 532216 532403 +187
- Misses 73380 73536 +156
Partials 364 364 |
2467a33 to
2f607b6
Compare
| # delete the "smaller" groups first | ||
| group_list.sort(key=lambda g: (g.times_seen, g.id)) | ||
| group_ids = [] | ||
| error_ids = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this variable anymore, thus, removing the whole block.
|
|
||
| # Removing GroupHash rows prevents new events from associating to the groups | ||
| # we just deleted. | ||
| GroupHash.objects.filter(project_id=project.id, group__id__in=group_ids).delete() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markstory The group is already marked as pending deletion, thus, the customer can't even see the group.
See lines 67-69:
| create_audit_entries(request, project, group_list, delete_type, transaction_id) | ||
|
|
||
| # Tell seer to delete grouping records for these groups | ||
| call_delete_seer_grouping_records_by_hash(error_ids) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this call to seer fails then the task is not get scheduled.
This is one of the main reasons we have so many groups in a pending deletion state.
Redash query: https://redash.getsentry.net/queries/9170/source
During the API call we were doing work that the Group model already does.
2f607b6 to
449c4dd
Compare
| add_group_to_inbox(group, GroupInboxReason.NEW) | ||
|
|
||
| delete_groups(request, [self.project], self.organization.id) | ||
| with self.tasks(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the task does not execute the hashes will still exist.
|
|
||
| @patch("sentry.api.helpers.group_index.delete.may_schedule_task_to_delete_hashes_from_seer") | ||
| @patch("sentry.utils.audit.log_service.record_audit_log") | ||
| def test_audit_log_even_if_exception_raised( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test does not make sense after this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Group Deletion Logic Inconsistency
The GroupHash deletion was removed from the delete_group_list API endpoint, despite PR discussion acknowledging the need to restore it. This allows new events to associate with groups marked as PENDING_DELETION during the window before the asynchronous deletion task completes. This contradicts the original intent to prevent such associations and is inconsistent with the retained GroupInbox deletion logic.
src/sentry/api/helpers/group_index/delete.py#L78-L84
sentry/src/sentry/api/helpers/group_index/delete.py
Lines 78 to 84 in c49bea9
| # We remove `GroupInbox` rows here so that they don't end up influencing queries for | |
| # `Group` instances that are pending deletion | |
| GroupInbox.objects.filter(project_id=project.id, group__id__in=group_ids).delete() | |
| delete_groups_task.apply_async( | |
| kwargs={ |
Was this report helpful? Give feedback by reacting with 👍 or 👎
We don't want to delete GroupHash since it will be needed during the task execution to call Seer. |
lobsterkatie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
markstory
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me. Consolidating the deletion logic is a great idea.
When deleting an issue, a failure to query the DB would prevent scheduling the group deletion task. From the customer's perspective, it would look that the group has been deleted, however, all relationships would still be left behind. The biggest problem would be that the group hashes are left behind, thus, any new events matching those group hashes would not create a new issue. This is a better fix than the one proposed in #93541. Fixes #93509. Fixes [ID-716](https://linear.app/getsentry/issue/ID-716/)
This is the test missing from #93541 that would have prevented the regression.
This is the test missing from #93541 that would have prevented the regression.
When deleting an issue, a failure to query the DB would prevent scheduling the group deletion task. From the customer's perspective, it would look that the group has been deleted, however, all relationships would still be left behind. The biggest problem would be that the group hashes are left behind, thus, any new events matching those group hashes would not create a new issue. This is a better fix than the one proposed in #93541. Fixes #93509. Fixes [ID-716](https://linear.app/getsentry/issue/ID-716/)
During the deletion API call we were calling seer & a couple more changes which the Group deletion model already does, thus, we don't need to do it during the API call. Prior to this change, if the Seer call failed, the deletion task would not get scheduled, thus, many groups stay in a pending deletion state and never deleted. Fixes #93509 Fixes [ID-716](https://linear.app/getsentry/issue/ID-716/move-endpoint-code-to-the-deletion-task)
This is the test missing from #93541 that would have prevented the regression.
When deleting an issue, a failure to query the DB would prevent scheduling the group deletion task. From the customer's perspective, it would look that the group has been deleted, however, all relationships would still be left behind. The biggest problem would be that the group hashes are left behind, thus, any new events matching those group hashes would not create a new issue. This is a better fix than the one proposed in #93541. Fixes #93509. Fixes [ID-716](https://linear.app/getsentry/issue/ID-716/)
During the deletion API call we were calling seer & a couple more changes which the Group deletion model already does, thus, we don't need to do it during the API call.
Prior to this change, if the Seer call failed, the deletion task would not get scheduled, thus, many groups stay in a pending deletion state and never deleted.
Fixes #93509
Fixes ID-716