-
Notifications
You must be signed in to change notification settings - Fork 102
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 recursive delete on hierarchical namespace accounts #454
Merged
TomAugspurger
merged 14 commits into
fsspec:main
from
Tom-Newton:tomnewton/delete_directory_markers_after_other_blobs
Jan 28, 2024
Merged
Fix recursive delete on hierarchical namespace accounts #454
TomAugspurger
merged 14 commits into
fsspec:main
from
Tom-Newton:tomnewton/delete_directory_markers_after_other_blobs
Jan 28, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tom-Newton
commented
Jan 26, 2024
This was referenced Jan 26, 2024
Closed
cc @daavoo do you have a chance to look at this? |
I think all the lint failures should be resolved now. |
TomAugspurger
approved these changes
Jan 28, 2024
Looks good, thanks. Just removed a print statement in the tests. I'll merge once CI passes. |
Thanks @Tom-Newton! |
Thank you @Tom-Newton ! |
Thanks a lot! @efiop would you folks have already a date in mind to cut a release containing this patch? |
@gdippolito Thanks for reminding! 2024.1.0 is out now. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves: #389
Alternative fix to #453
Unfortunately #383 broke recursive delete on blob storage accounts with hierarchical namespace enabled (ADLS gen2).
This is because #383 causes all blobs (including hierarchical namespace directory markers) do be deleted asynchronously. There is nothing to ensure that the contents of a directory are deleted before the directory itself, hence the error above.
Chosen fix
Look at the sorted list of blob names to derive which blobs are directory markers so they can be deleted in the correct order. Other blobs are deleted asynchronously. The strategy used for this is a bit strange but I think its the best option, at least for now.
Alternative solutions:
container_client.delete_blobs()
azurite
delete_blobs method raises an exception PartialBatchErrorException when using Azurite Azure/Azurite#1809delete_directory
API on hierarchical namespace accounts can automatically delete the directory recursively with no need to explicitly list all the blobs it contains https://learn.microsoft.com/en-us/python/api/azure-storage-file-datalake/azure.storage.filedatalake.datalakedirectoryclient?view=azure-python#azure-storage-filedatalake-datalakedirectoryclient-delete-directoryHdi_isfolder=true
.expand_path=False
specifically to get this optimisation.Testing
The currently existing test
test_rm_recursive
catches this bug if it is run against a hierarchical namespace storage account. I provisioned a real hierarchical namespace account to run this test against.I added an assertion to
test_rm_recursive
that the directory marker is the last delete.I also added a test that deletes more directories. To implement this I changed the
storage
fixture to havefunction
scope to reset it after every test. This doesn't seem to impact the runtime of the tests so I assume this is ok.