Skip to content

Commit

Permalink
ref(escalating-issues): Auto-transition tasks should update up to 500…
Browse files Browse the repository at this point in the history
…_000 groups per minute (#56168)

## Objective:

The current implementation of the auto-transition tasks is leading to
spiky memory pressure on RabbitMQ. This is partly due to the hot shards
of big orgs with a lot of groups. The alternative approach is to
consistently send x number of messages of groups older than 7 days. No
need to care about org or project bc all those groups have the same
status and substatus changes. This iteration sends up to 50 child tasks
with each task updating 10_000 groups. We will increase the number of
tasks if the backlog of groups_to_be_updated is increasing.
  • Loading branch information
NisanthanNanthakumar committed Sep 20, 2023
1 parent 46b3e77 commit 58ee52a
Show file tree
Hide file tree
Showing 6 changed files with 514 additions and 138 deletions.
4 changes: 2 additions & 2 deletions src/sentry/conf/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1131,8 +1131,8 @@ def SOCIAL_AUTH_DEFAULT_USERNAME() -> str:
},
"schedule_auto_transition_to_ongoing": {
"task": "sentry.tasks.schedule_auto_transition_to_ongoing",
# Run job every 10 minutes
"schedule": crontab(minute="*/10"),
# Run job every minute
"schedule": crontab(minute="*/1"),
"options": {"expires": 3600},
},
"github_comment_reactions": {
Expand Down
6 changes: 3 additions & 3 deletions src/sentry/issues/ongoing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
def bulk_transition_group_to_ongoing(
from_status: int,
from_substatus: int,
groups: List[Group],
group_ids: List[int],
activity_data: Optional[Mapping[str, Any]] = None,
) -> None:
# make sure we don't update the Group when its already updated by conditionally updating the Group
groups_to_transistion = Group.objects.filter(
id__in=[group.id for group in groups], status=from_status, substatus=from_substatus
id__in=group_ids, status=from_status, substatus=from_substatus
)

Group.objects.update_group_status(
Expand All @@ -31,7 +31,7 @@ def bulk_transition_group_to_ongoing(
group.status = GroupStatus.UNRESOLVED
group.substatus = GroupSubStatus.ONGOING

bulk_remove_groups_from_inbox(groups)
bulk_remove_groups_from_inbox(groups_to_transistion)

for group in groups_to_transistion:
post_save.send_robust(
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/issues/update_inbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def update_inbox(
bulk_transition_group_to_ongoing(
group.status,
group.substatus,
[group],
[group.id],
activity_data={"manually": True},
)

Expand Down
Loading

0 comments on commit 58ee52a

Please sign in to comment.