Repository navigation
fix(backend): handle missing ArangoDB documents on delete - #10701
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
|
is celery compatible with arangodb 4.x? |
|
No it is not compatible. But my AQL syntax itself is compatible with both ArangoDB 3.x and 4.x. |
|
OK |
MehrazRumman
left a comment
There was a problem hiding this comment.
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_documentasserts exactly the same call as the updatedtest_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_deleteassertion 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.
Summary
Fix: #10700
Changes
OPTIONS { ignoreErrors: true }to the ArangoDBREMOVEquery.ignoreErrorsoption 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