Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10702 +/- ##
=======================================
Coverage 89.73% 89.74%
=======================================
Files 153 153
Lines 20515 20518 +3
Branches 2448 2448
=======================================
+ Hits 18410 18413 +3
Misses 1803 1803
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. |
|
@MehrazRumman check this too |
MehrazRumman
left a comment
There was a problem hiding this comment.
Thanks @simpleqt. The change is correct: catching only FileNotFoundError around self.unlink() makes forget() / GroupResult.delete() idempotent, and still surfaces PermissionError and other OSErrors.
However, this is the same fix as #10678 (also yours), which makes the identical change to FilesystemBackend.delete(). Neither is merged yet, so we should land only one. The two PRs have complementary tests:
- #10678:
test_forget_missing_task_is_noopandtest_forget_twice_is_noop(same task id, stored then forgotten twice). - #10702:
test_forget_missing_task_is_idempotentandtest_delete_missing_key_is_idempotent(callsdelete()directly).
Suggestion: keep one PR (either is fine; #10678 is older and has the "forget twice" test), bring the delete()-level test over from this one, and close the other as a duplicate. @auvipy, your call on which to keep.
While you're touching delete(), the point from my review on #10678 applies here too: cleanup() has the same missing-file race (os.stat() / self.unlink() after os.listdir() can raise FileNotFoundError if a concurrent forget() or another cleanup() removed the file first, which aborts the rest of the pass). Wrapping that with the same except FileNotFoundError would complete the idempotency fix for this backend.
One more heads-up: #10703 (atomic writes) changes the same file, so whichever lands second will need a trivial rebase.
|
@MehrazRumman can you combine all 3 pr related to filesytem fix and create a new single pr? this will reduce distraction for maintainers |
|
Okay ! Thanks @auvipy ! |
Problem
FilesystemBackend.deleteis not idempotent, unlike every otherKeyValueStoreBackendimplementation:redis(client.delete) andcache(cache.pop(key, None)) both tolerate missing keys, but the filesystem backend raisesFileNotFoundError.AsyncResult.forget()andGroupResult.delete()are public cleanup APIs that are most needed when a result was never stored or has already been removed (e.g. bycleanup()), and they crash on this backend:Fix
Swallow
FileNotFoundErrorindelete, matching the idempotent contract of the other key-value backends (getin the same class already handlesFileNotFoundErrorthe same way).Test plan
Two regression tests in
t/unit/backends/test_filesystem.py:forget()on a task id that was never storeddelete()on a missing result keyBoth fail on
main(verified by stashing the fix) and pass with it. flake8 (repo config) clean.