Repository navigation
Only remove expired results in the ArangoDB backend's cleanup() - #11125
Open
MehrazRumman wants to merge 7 commits into
Open
MehrazRumman wants to merge 7 commits into
MehrazRumman wants to merge 7 commits into
Conversation
The backend stores each result as the encoded meta, a JSON string, in the document's task field. cleanup() filtered on record.task.date_done, which is null on a string, and AQL sorts null before any value, so every result was removed, including ones stored a moment ago and tasks still running. celery.backend_cleanup runs this daily under beat. Parse the JSON to read date_done, skip results without one, and compare instants with DATE_TIMESTAMP() instead of ISO strings, which can carry different UTC offsets.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11125 +/- ##
=======================================
Coverage 91.35% 91.35%
=======================================
Files 153 153
Lines 21889 21889
Branches 2721 2721
=======================================
Hits 19997 19997
Misses 1590 1590
Partials 302 302
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
This was referenced Nov 18, 2026
auvipy
self-requested a review
November 19, 2026 09:29
auvipy
reviewed
Nov 24, 2026
| def cleanup(self): | ||
| if not self.expires: | ||
| return | ||
| checkpoint = (self.app.now() - self.expires_delta).isoformat() |
Member
There was a problem hiding this comment.
is removing the isoformat fixing this bug?
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: Before submitting this pull request, please review our contributing
guidelines & [Anti AI spamming Guidelines] (#10932). Before opening an AI based PR make sure you asked
in the discussion forum or in the related open issues first.
Description
Fixes #11122
The ArangoDB backend stores each result as the encoded meta, a JSON string, in the document's
taskfield.cleanup()filtered onrecord.task.date_done < @checkpoint. On a string.date_doneisnull, which AQL sorts before any string, so every document was removed, including results stored a moment before and tasks still running.celery.backend_cleanupruns this daily under beat.The query now parses
taskwithJSON_PARSE()(or uses it as is if it's already an object), skips documents without adate_done, and comparesDATE_TIMESTAMP(meta.date_done)with the cutoff in milliseconds, rather than comparing ISO strings, which can carry different UTC offsets.Only
celery/backends/arangodb.pychanges. Documents without adate_doneare kept now, wheremainremoved them. That includes group results saved withGroupResult.save(), which only storeresult, socleanup()no longer removes them at all.Tests
Against ArangoDB 3.12.13 in Docker with pyArango 2.1.1,
result_expires=86400. One result was stored now, one with itsdate_doneset two days back, and one task was left STARTED, thencleanup()ran:timezonemainI also checked in AQL that
DATE_TIMESTAMP()reads Python'sisoformat()with microseconds and offsets:"2026-11-17T09:00:00.123456+09:00"and"2026-11-17T00:00:00.123456+00:00"give the same value.DATE_TIMESTAMP(null)isnull, hence the explicitdone != null.test_backend_cleanupint/unit/backends/test_arangodb.pyasserted the old query text. It now checks that the query parsestask, filters outnull, and gets the cutoff as a millisecond timestamp. It fails onmainand passes here.pytest t/unit/backends/test_arangodb.py: 14 passed. pre-commit passes on both files.Not run: the integration and smoke suites. CI has no ArangoDB.