Skip to content

Commit 2a2afa2

Browse files
authored
fix(aci): Fix QuerySubscription deletion (#103398)
We have logic to ensure that SnubaQuery deletions are triggered by QuerySubscription deletion only if the SnubaQuery isn't used by AlertRules or other QuerySubscriptions. This changes it to not exclude snapshot AlertRules, as those can still point to a SnubaQuery and fail attempts to delete it. Fixes [SENTRY-43RZ](https://sentry.sentry.io/issues/6711913108/).
1 parent ae19b87 commit 2a2afa2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/sentry/deletions/defaults/querysubscription.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ def get_child_relations(self, instance: QuerySubscription) -> list[BaseRelation]
1414
from sentry.incidents.models.alert_rule import AlertRule
1515
from sentry.snuba.models import SnubaQuery
1616

17-
if not AlertRule.objects.filter(snuba_query_id=instance.snuba_query_id).exists():
17+
if not AlertRule.objects_with_snapshots.filter(
18+
snuba_query_id=instance.snuba_query_id
19+
).exists():
1820
if (
1921
QuerySubscription.objects.filter(snuba_query_id=instance.snuba_query_id).count()
2022
== 1

0 commit comments

Comments
 (0)