Skip to content

Commit 76b9bdf

Browse files
authored
fix(cleanup) Don't call QuerySet.__bool__ (#68991)
Conditions like `if queryset:` will evaluate the full query set and load results into memory. When cleanup is run for all projects this causes an OOM error.
1 parent fcd123d commit 76b9bdf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/sentry/runner/commands/cleanup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def is_filtered(model: type[Model]) -> bool:
352352
else:
353353
to_delete_by_project.append(model_tp_tup)
354354

355-
if project_deletion_query and to_delete_by_project:
355+
if project_deletion_query is not None and len(to_delete_by_project):
356356
debug_output("Running bulk deletes in DELETES_BY_PROJECT")
357357
for project_id_for_deletion in RangeQuerySetWrapper(
358358
project_deletion_query.values_list("id", flat=True),

0 commit comments

Comments
 (0)