Repository navigation
Invalidate cached Drive directories after moves and removals - #408
shcheklein wants to merge 10 commits into
Conversation
shcheklein
left a comment
There was a problem hiding this comment.
AI-generated review of 61d250680aa2787d0f97e48c427e7e9228bc3511.
Overall the explicit _directory_ids lifecycle and atomic snapshot swap in _without_subtree are clean and well-structured. Inline comments highlight a couple of concrete bugs (mv with implicit-root destinations, invalidate_cache("") on non-root mounts), two concurrency/cross-codebase effects (_create_dir unlocked list read and mv post-upload directory check), an unintended neutralization of an existing deduplication test, and a few targeted test/simplification improvements.
shcheklein
left a comment
There was a problem hiding this comment.
AI-generated re-review of 89c9518d9720b615f5893262200bfe54cc028459 (from scratch).
Looks solid and ready to merge. All earlier edge cases are cleanly resolved:
mv()normalizes both paths via_split_mounted_path(fixing implicit-root and trailing-slash moves), checksfile1.get("mimeType") == FOLDER_MIME_TYPEfrom the Drive update response (closing the concurrent-eviction gap), and invalidates both subtrees atomically via_invalidate_paths.invalidate_cache("")works on folder-ID mounts,_create_dirreads/writes under_cache_lockon the resolvedcachesnapshot, and the HTTP-level tests intest_fs_unit.py+ live test intest_fs.pycover all key paths cleanly (including paginated duplicate-ID deduplication inls).
No new bugs or simplifications to flag.
|
The stale-descendant report reproduced on both The fix evicts the affected descendants and detaches older in-flight lookups from the active cache. Traversal uses current Drive parent IDs to assemble paths, including when the child arrives before the parent. Regression tests cover both response orders, duplicate directory names, a lookup finishing during the rename, and an unrelated warm sibling. I kept invalidation scoped. A global reset would turn the next lookup of that sibling from zero Drive requests into a fresh path resolution. Ordinary file removals continue to skip directory-cache invalidation. The typed path resolver in this PR also serves the stacked mkdir and find changes. |
|
Addressed the locking and resolver feedback. Name lookup now returns the deepest resolved component without creating anything. Folder creation coordinates by filesystem instance, Drive parent ID and name. Mount discovery and metadata requests run outside the general cache lock. The overlap tests exercise two unrelated creates both on one instance and across instances. The larger parent-edge cache and generation change is tracked in #413. It documents how snapshots invalidate today, where CPU and memory costs grow, and how to measure the replacement. DVC has a concrete reason to preserve batching: its Google Drive adapter favors traversal under quota pressure, and #393 records a real failure on 251 cache prefixes. I exercised the real dvc-gdrive adapter and dvc-objects against a simulated Drive at both fsspec 2024.2.0 and 2026.9.0. The adapter's 251-folder traversal took seven requests cold and six warm. A single warm object existence check took one request. |
|
Fixed the same-filesystem duplicate-create race in 156e028. Two writers could both miss The public
The upload benchmark used eight workers with a simulated 25 ms folder create. The remaining scaling concern is selective invalidation: the directory-index copy holds the general cache lock. On #411 the median hold was about 0.10 ms for 256 cached folders, 4 ms for 10,000 and 54 ms for 100,000. DVC's |
Fixes #232.
Directory moves and removals used to leave stale descendants in the path-to-ID cache. The same problem occurred when another Drive client moved a folder and PyDrive2 rediscovered its ID at a different path.
The shared path resolver retains matching folder IDs, including duplicate names, and returns fresh file metadata. Directory mutations replace the affected portion of the cache so older lookups can finish without repopulating it. Batched traversal builds paths from the current Drive parent links, even when children are returned before their renamed parent.
The tests cover local and external moves, trash, failed operations, duplicate names, in-flight lookups, and exact request counts. The live deep-path caching benchmark and its HTTP-level counterpart cover cold creation and warm reads. #409 and #411 build on this foundation.