-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix behavior for OOB move followed by IB move #63
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #63 +/- ##
==========================================
- Coverage 86.03% 85.49% -0.54%
==========================================
Files 5 5
Lines 537 531 -6
Branches 69 68 -1
==========================================
- Hits 462 454 -8
- Misses 53 55 +2
Partials 22 22
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
Oh wait, this gets a little more tricky because this is technically a breaking change. Let me explain: Imagine a user indexes a file at # test for disjoint move handling
# disjoint move: any out-of-band move that does not preserve stat info
def test_disjoint_move_indexed(any_fid_manager, old_path, new_path, fs_helpers):
old_id = any_fid_manager.index(old_path)
fs_helpers.delete(old_path)
fs_helpers.touch(new_path, dir=True)
new_id = any_fid_manager.move(old_path, new_path)
assert old_id == new_id I think this is fine, given that a proper filesystem move should be done before calling |
Honestly, sometimes I'm blown away by how smart |
@dleen Could you pull this branch locally and verify this fixes your issue? |
Very nice @dlqqq ! I took a quick look and I noticed a small issue - the path doesn't seem to get updated in the DB. So after I rename to
I think you might be able to see this if you include fetching by path in your test? Or does fetching by path have the side effect of updating the DB? |
I'm checking locally but I think in the test:
Edit: nevermind I see that's supposed to be the equivalent of a contents manager move |
Figured it out - it's because |
@dlqqq not sure how to update this PR with my change - feel free to cherry-pick it. Not sure why the test didn't catch this... |
Confirming that with my additional patch it works as expected |
@dleen Thank you for reporting the bug and finding that edge case I missed! 🤗 I'll merge this and cut a release for you.
The SQLite client will allow you to query uncommitted transactions so long as it's done on the same DB connection. Hence, you can imagine that this is quite tricky to test; I think a good compromise is implementing a declarative way of automatically committing after public method invocation via decorators. This would provide us a strong guarantee of File ID behaving properly without having to write complex testing logic. See here: #64 |
The reason this bug exists is because LocalFIDM didn't consider mixing out-of-band and in-band filesystem operations. This meant that originally, we did not call
_sync_file()
inmove()
, because we assumed the file was not moved out-of-band after it was indexed. This optimization was done for performance reasons, as the_sync_*
methods are a little expensive.However, as @dleen describes in the original issue, this error state is too easy to reach, and should be properly handled by LocalFIDM.