Skip to content

ArangoDB backend: cleanup() deletes every result, including ones just stored #11122

Open

Description

@MehrazRumman

Checklist

  • I have verified that the issue exists against the main branch of Celery.
  • This has already been asked to the discussions forum first.
  • I have read the relevant section in the
    contribution guide
    on reporting bugs.
  • I have checked the issues list
    for similar or identical bug reports.
  • I have checked the pull requests list
    for existing proposed fixes.
  • I have checked the commit log
    to find out if the bug was already fixed in the main branch.
  • I have included all related issues and possible duplicate issues
    in this issue (If there are none, check this box anyway).
  • I have tried to reproduce the issue with pytest-celery and added the reproduction script below.

Mandatory Debugging Information

  • I have included the output of celery -A proj report in the issue.
    (if you are not able to do this, then at least specify the Celery
    version affected).
  • I have verified that the issue exists against the main branch of Celery.
  • I have included the contents of pip freeze in the issue.
  • I have included all the versions of all the external dependencies required
    to reproduce this bug.

Related Issues and Possible Duplicates

Related Issues

Possible Duplicates

  • None

Environment & Settings

Celery version: main at 9c2f238 (5.7.0)

Steps to Reproduce

Required Dependencies

  • Minimal Python Version: N/A or Unknown
  • Minimal Celery Version: N/A or Unknown
  • Minimal Kombu Version: N/A or Unknown
  • Minimal Broker Version: N/A or Unknown
  • Minimal Result Backend Version: ArangoDB 3.12.13
  • Minimal OS and/or Kernel Version: N/A or Unknown
  • Minimal Broker Client Version: N/A or Unknown
  • Minimal Result Backend Client Version: pyArango 2.1.1

I ran it with Python 3.14.

Minimally Reproducible Test Case

$ docker run -d -p 8529:8529 -e ARANGO_ROOT_PASSWORD=pw arangodb:3.12
$ curl -u root:pw -X POST http://127.0.0.1:8529/_api/database -d '{"name":"celery"}'
$ curl -u root:pw -X POST http://127.0.0.1:8529/_db/celery/_api/collection -d '{"name":"celery"}'
from uuid import uuid4
from celery import Celery, states

app = Celery(set_as_current=False,
             backend='arangodb://root:[email protected]:8529/celery/celery')
app.conf.result_expires = 86400   # one day
b = app.backend

done, running = uuid4().hex, uuid4().hex
b.store_result(done, 42, states.SUCCESS)
b.store_result(running, None, states.STARTED)
b.cleanup()   # what celery.backend_cleanup runs
print(b.get_task_meta(done, cache=False)['status'],
      b.get_task_meta(running, cache=False)['status'])

Expected Behavior

SUCCESS STARTED: neither result is older than result_expires.

Actual Behavior

PENDING PENDING: both documents are gone, and the collection is empty.

The backend stores each result as the encoded meta, a JSON string, in the document's task field (INSERT {_key: @key, task: @value}). cleanup() filters on record.task.date_done < @checkpoint. On a string .date_done is null, and AQL sorts null before any string, so the filter matches every document. Here RETURN DOCUMENT("celery/<key>").task.date_done returns null for a stored SUCCESS. celery.backend_cleanup runs this every day when beat runs.

Parsing the JSON in the query, skipping documents without a date_done, and comparing with DATE_TIMESTAMP() fixes it. Comparing the ISO strings as they are would also go wrong when they carry different UTC offsets, for example across a DST change.

Activity

  1. added this to the 5.7.x milestone on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions