Skip to content

Commit

Permalink
fix(escalating-issues): Delete count query causing Postgres timeouts (#…
Browse files Browse the repository at this point in the history
…57718)

## Objective:

Quick fix to delete the offending query causing Postgres timeouts. This
query is only used for metrics. We will find another way to get this
data.

Fixes SENTRY-16DC
  • Loading branch information
NisanthanNanthakumar authored Oct 6, 2023
1 parent 96b4403 commit 996f53a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 81 deletions.
36 changes: 0 additions & 36 deletions src/sentry/tasks/auto_ongoing_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ def get_total_count(results):
id__lte=most_recent_group_first_seen_seven_days_ago.id,
)

groups_to_update_count = base_queryset._clone().count()

with sentry_sdk.start_span(description="iterate_chunked_group_ids"):
for new_group_ids in chunked(
RangeQuerySetWrapper(
Expand All @@ -162,21 +160,11 @@ def get_total_count(results):
group_ids=new_group_ids,
)

with sentry_sdk.start_span(description="get_remaining_groups") as span:
remaining_groups = groups_to_update_count - total_count

span.set_tag("remaining_groups", remaining_groups)

metrics.incr(
"sentry.tasks.schedule_auto_transition_issues_new_to_ongoing.executed",
sample_rate=1.0,
tags={"count": total_count},
)
metrics.incr(
"sentry.tasks.schedule_auto_transition_issues_new_to_ongoing.remaining",
sample_rate=1.0,
tags={"count": remaining_groups},
)


@instrumented_task(
Expand Down Expand Up @@ -247,8 +235,6 @@ def get_total_count(results):
.filter(recent_regressed_history__lte=datetime.fromtimestamp(date_added_lte, timezone.utc))
)

groups_to_update_count = base_queryset._clone().count()

with sentry_sdk.start_span(description="iterate_chunked_group_ids"):
for group_ids_with_regressed_history in chunked(
RangeQuerySetWrapper(
Expand All @@ -264,21 +250,11 @@ def get_total_count(results):
group_ids=group_ids_with_regressed_history,
)

with sentry_sdk.start_span(description="get_remaining_groups") as span:
remaining_groups = groups_to_update_count - total_count

span.set_tag("remaining_groups", remaining_groups)

metrics.incr(
"sentry.tasks.schedule_auto_transition_issues_regressed_to_ongoing.executed",
sample_rate=1.0,
tags={"count": total_count},
)
metrics.incr(
"sentry.tasks.schedule_auto_transition_issues_regressed_to_ongoing.remaining",
sample_rate=1.0,
tags={"count": remaining_groups},
)


@instrumented_task(
Expand Down Expand Up @@ -349,8 +325,6 @@ def get_total_count(results):
.filter(recent_escalating_history__lte=datetime.fromtimestamp(date_added_lte, timezone.utc))
)

groups_to_update_count = base_queryset._clone().count()

with sentry_sdk.start_span(description="iterate_chunked_group_ids"):
for new_group_ids in chunked(
RangeQuerySetWrapper(
Expand All @@ -366,21 +340,11 @@ def get_total_count(results):
group_ids=new_group_ids,
)

with sentry_sdk.start_span(description="get_remaining_groups") as span:
remaining_groups = groups_to_update_count - total_count

span.set_tag("remaining_groups", remaining_groups)

metrics.incr(
"sentry.tasks.schedule_auto_transition_issues_escalating_to_ongoing.executed",
sample_rate=1.0,
tags={"count": total_count},
)
metrics.incr(
"sentry.tasks.schedule_auto_transition_issues_escalating_to_ongoing.remaining",
sample_rate=1.0,
tags={"count": remaining_groups},
)


@instrumented_task(
Expand Down
48 changes: 3 additions & 45 deletions tests/sentry/tasks/test_auto_ongoing_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,32 +201,18 @@ def test_not_all_groups_get_updated(self, mock_backend, mock_metrics_incr):
sample_rate=1.0,
tags={"count": 100},
)
mock_metrics_incr.assert_any_call(
"sentry.tasks.schedule_auto_transition_issues_new_to_ongoing.remaining",
sample_rate=1.0,
tags={"count": 10},
)

mock_metrics_incr.assert_any_call(
"sentry.tasks.schedule_auto_transition_issues_regressed_to_ongoing.executed",
sample_rate=1.0,
tags={"count": 0},
)
mock_metrics_incr.assert_any_call(
"sentry.tasks.schedule_auto_transition_issues_regressed_to_ongoing.remaining",
sample_rate=1.0,
tags={"count": 0},
)

mock_metrics_incr.assert_any_call(
"sentry.tasks.schedule_auto_transition_issues_escalating_to_ongoing.executed",
sample_rate=1.0,
tags={"count": 0},
)
mock_metrics_incr.assert_any_call(
"sentry.tasks.schedule_auto_transition_issues_escalating_to_ongoing.remaining",
sample_rate=1.0,
tags={"count": 0},
)


@apply_feature_flag_on_cls("organizations:escalating-issues")
Expand Down Expand Up @@ -318,32 +304,18 @@ def test_not_all_groups_get_updated(self, mock_backend, mock_metrics_incr):
sample_rate=1.0,
tags={"count": 0},
)
mock_metrics_incr.assert_any_call(
"sentry.tasks.schedule_auto_transition_issues_new_to_ongoing.remaining",
sample_rate=1.0,
tags={"count": 0},
)

mock_metrics_incr.assert_any_call(
"sentry.tasks.schedule_auto_transition_issues_regressed_to_ongoing.executed",
sample_rate=1.0,
tags={"count": 100},
)
mock_metrics_incr.assert_any_call(
"sentry.tasks.schedule_auto_transition_issues_regressed_to_ongoing.remaining",
sample_rate=1.0,
tags={"count": 10},
)

mock_metrics_incr.assert_any_call(
"sentry.tasks.schedule_auto_transition_issues_escalating_to_ongoing.executed",
sample_rate=1.0,
tags={"count": 0},
)
mock_metrics_incr.assert_any_call(
"sentry.tasks.schedule_auto_transition_issues_escalating_to_ongoing.remaining",
sample_rate=1.0,
tags={"count": 0},
)


@apply_feature_flag_on_cls("organizations:escalating-issues")
Expand Down Expand Up @@ -436,29 +408,15 @@ def test_not_all_groups_get_updated(self, mock_backend, mock_metrics_incr):
sample_rate=1.0,
tags={"count": 0},
)
mock_metrics_incr.assert_any_call(
"sentry.tasks.schedule_auto_transition_issues_new_to_ongoing.remaining",
sample_rate=1.0,
tags={"count": 0},
)

mock_metrics_incr.assert_any_call(
"sentry.tasks.schedule_auto_transition_issues_regressed_to_ongoing.executed",
sample_rate=1.0,
tags={"count": 0},
)
mock_metrics_incr.assert_any_call(
"sentry.tasks.schedule_auto_transition_issues_regressed_to_ongoing.remaining",
sample_rate=1.0,
tags={"count": 0},
)

mock_metrics_incr.assert_any_call(
"sentry.tasks.schedule_auto_transition_issues_escalating_to_ongoing.executed",
sample_rate=1.0,
tags={"count": 100},
)
mock_metrics_incr.assert_any_call(
"sentry.tasks.schedule_auto_transition_issues_escalating_to_ongoing.remaining",
sample_rate=1.0,
tags={"count": 10},
)

0 comments on commit 996f53a

Please sign in to comment.