Skip to content

Commit 7a2d7f0

Browse files
authored
feat(deletions): Cleanup more groups per project (#103851)
Instead of deleting 10k groups let's remove 30k per project. There's also some other minor code removal.
1 parent 1197cfa commit 7a2d7f0

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

src/sentry/runner/commands/cleanup.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -739,13 +739,6 @@ def run_bulk_deletes_by_project(
739739
if project_deletion_query is not None and len(to_delete_by_project):
740740
debug_output("Running bulk deletes in DELETES_BY_PROJECT")
741741

742-
# Count total projects for progress tracking
743-
total_projects = project_deletion_query.count()
744-
debug_output(f"Processing {total_projects} project(s)")
745-
746-
processed_count = 0
747-
last_reported_percentage = 0
748-
749742
for project_id_for_deletion in RangeQuerySetWrapper(
750743
project_deletion_query.values_list("id", flat=True),
751744
result_value_getter=lambda item: item,
@@ -767,7 +760,7 @@ def run_bulk_deletes_by_project(
767760
order_by=order_by,
768761
)
769762

770-
for chunk in q.iterator(chunk_size=100):
763+
for chunk in q.iterator(chunk_size=100, batch_size=30000):
771764
task_queue.put((imp, chunk))
772765
except Exception:
773766
capture_exception(
@@ -780,17 +773,6 @@ def run_bulk_deletes_by_project(
780773
sample_rate=1.0,
781774
)
782775

783-
# Update progress tracking after processing all models for this project
784-
processed_count += 1
785-
current_percentage = int((processed_count / total_projects) * 100)
786-
787-
# Report progress every 5% to avoid excessive output
788-
if current_percentage >= last_reported_percentage + 5:
789-
debug_output(
790-
f"Progress: {current_percentage}% ({processed_count}/{total_projects} projects processed) (last_project_id: {project_id_for_deletion})"
791-
)
792-
last_reported_percentage = current_percentage
793-
794776
# Ensure all tasks are completed before exiting
795777
task_queue.join()
796778

0 commit comments

Comments
 (0)