Skip to content

fix(backend): handle missing ArangoDB documents on delete - #10701

Merged
auvipy merged 2 commits into
celery:mainfrom
Namraa310806:fix/arangodb-delete-missing-document
Sep 27, 2026
Merged

auvipy merged 2 commits into
celery:mainfrom
Namraa310806:fix/arangodb-delete-missing-document

Conversation

@Namraa310806

Copy link
Copy Markdown
Contributor

Summary

Fix: #10700

Changes

  • Add OPTIONS { ignoreErrors: true } to the ArangoDB REMOVE query.
  • Update the existing delete test to expect the new query.
  • Add regression coverage verifying the ignoreErrors option is included for missing-document deletion.

This keeps deletion idempotent while preserving the existing delete(None) behavior and avoiding broad exception handling.

Tests

  • pytest t/unit/backends/test_arangodb.py — 14 passed

@Namraa310806
Namraa310806 marked this pull request as ready for review September 24, 2026 13:54
@codecov

codecov Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.44%. Comparing base (dcd62a2) to head (fc5ac6d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10701   +/-   ##
=======================================
  Coverage   89.44%   89.44%           
=======================================
  Files         153      153           
  Lines       20414    20414           
  Branches     2434     2434           
=======================================
  Hits        18260    18260           
  Misses       1851     1851           
  Partials      303      303           
Flag Coverage Δ
unittests 89.42% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@auvipy auvipy added this to the 5.7.0 milestone Sep 24, 2026
@auvipy

auvipy commented Sep 24, 2026

Copy link
Copy Markdown
Member

is celery compatible with arangodb 4.x?

@Namraa310806

Copy link
Copy Markdown
Contributor Author

No it is not compatible.
Celery's current ArangoDB backend uses pyArango, whose supported ArangoDB versions are 3.x. So in the context of Celery's current implementation, this fix applies to the existing ArangoDB 3.x backend.

But my AQL syntax itself is compatible with both ArangoDB 3.x and 4.x.

@auvipy

auvipy commented Sep 24, 2026

Copy link
Copy Markdown
Member

OK

@MehrazRumman MehrazRumman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @Namraa310806, this is a small, targeted fix for #10700.

The fix

Adding OPTIONS { ignoreErrors: true } to the REMOVE query is the right way to make deletion idempotent in ArangoDB. It avoids a round trip, and it avoids catching pyArango's generic AQLQueryError and inspecting its error number in Python. It also brings ArangoDB in line with the other key-value backends where forget() on a missing result is a no-op (Redis, cache, DynamoDB, and Couchbase / Elasticsearch / CouchDB with #10697). The delete(None) early return is unchanged.

On @auvipy's question: the OPTIONS { ignoreErrors: ... } clause on REMOVE has been in AQL since the 2.x/3.0 days, so there's no compatibility concern for the ArangoDB versions pyArango supports.

Worth considering: ignoreErrors is broader than "not found"

ignoreErrors: true doesn't only suppress "document not found" (error 1202). It suppresses errors for the individual REMOVE operation in general, which I believe includes write-write conflicts (1200) in clustered or concurrent setups. For forget() that's arguably fine (the goal is "make sure it's gone"), but a silently ignored conflict could leave the document in place. Two options:

  • Accept it and say so in a short code comment, so the next reader knows the option is intentional and what it covers; or
  • Keep the query as it was and catch only the not-found case, e.g. except AQLQueryError as exc: checking for error 1202 and re-raising anything else.

I'm fine with the first, but please add the comment either way.

Tests

  • test_delete_uses_ignore_errors_for_missing_document asserts exactly the same call as the updated test_delete (the same query string and bind variables, only with a different sentinel key). Since everything is mocked, "missing document" isn't actually simulated, so the test doesn't add any coverage. I'd drop it, or rename it and say in a docstring that it only guards the query string.
  • A test with real behaviour would need an ArangoDB instance. If that isn't available in CI, the updated test_delete assertion is enough.

Summary

The change is correct and minimal. I'd approve once there's a short comment explaining the ignoreErrors choice, and the redundant test is dropped or clarified. Two other backends still raise on a missing key (Azure Block Blob ResourceNotFoundError, CosmosDB 404) and could be handled in a follow-up, so forget() behaves the same on every backend.

@auvipy
auvipy merged commit efdfad3 into celery:main Sep 27, 2026
396 checks passed
@Namraa310806
Namraa310806 deleted the fix/arangodb-delete-missing-document branch October 13, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ArangoDB: ArangoDbBackend.delete() raises when deleting a missing document

3 participants