Skip to content

Conversation

@saz
Copy link
Contributor

@saz saz commented Jun 23, 2025

fixes #430

@auvipy auvipy requested a review from Copilot June 23, 2025 15:38
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modifies the deletion of expired results to process records in batches, thereby reducing the likelihood of running out of memory. It also updates a benchmark test threshold to reflect the changes in deletion performance.

  • Adjust benchmark test assertion to allow higher timing.
  • Implement batched deletion in the manager to mitigate OOM issues.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
t/integration/benchmark_models.py Updated test assertion threshold from 1 to 5
django_celery_results/managers.py Introduced batched deletion with a configurable batch_size
Comments suppressed due to low confidence (2)

t/integration/benchmark_models.py:70

  • [nitpick] Consider adding a comment to explain why the threshold was increased from 1 to 5, clarifying the trade-off in benchmark performance due to the batched deletion implementation.
        assert self.benchmark.stats.stats.max < 5

django_celery_results/managers.py:87

  • [nitpick] Review the default batch_size value of 100000 to ensure that it is appropriate for production workloads; consider making this parameter externally configurable if necessary.
    def delete_expired(self, expires, batch_size=100000):

return self.filter(date_done__lt=now() - maybe_timedelta(expires))

def delete_expired(self, expires):
def delete_expired(self, expires, batch_size=100000):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we also add some unit test for this?

@saz saz force-pushed the batch-delete_expired branch from d2eba9f to c4c4e2c Compare July 2, 2025 11:46
@auvipy auvipy merged commit 05a9288 into celery:main Jul 2, 2025
25 checks passed
@saz saz deleted the batch-delete_expired branch July 2, 2025 12:24
@saz
Copy link
Contributor Author

saz commented Jul 21, 2025

@auvipy is there a chance to get a new release with this fix included?

@auvipy
Copy link
Member

auvipy commented Jul 21, 2025

yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

delete_expired method fails for large queryset.

2 participants