-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
shutil.rmtree(..., ignore_errors=True) doesn't ignore errors from os.close() #79513
Comments
These lines throw intermittently for me on AIX when removing a directory on NFS (python version 3.6.6-1), even when "ignore_errors=True": https://github.com/python/cpython/blob/v3.6.6rc1/Lib/shutil.py#L433 Should there be try-except blocks around these lines and calls to onerror(...)? |
I forgot to mention: the exception raised is an OSError and the errno is 52 (ESTALE on AIX). |
I am wondering whether we should silence that error in os.close() unconditionally. In what circumstances the error is raised? Can it be reproduced on Linux (by monkey-patching os.rmdir)? What can happen in worst case when the error is ignored? |
I've looked a bit into this and it seems like ESTALE can be caused in two cases:
https://www.ibm.com/support/pages/apar/IV50544
In the first case, the solution given is to run READDIR under a different CID. I've found the definition of CID just 10 minutes ago but now can't find it again :(. Anyway, it seems to be an ID corresponding to the WPAR environment. In the 2nd case, it's pretty clear that we shouldn't silence it: if you unmount a virtual partition while running rmtree on it, I'm 99.9% sure it was unintended! In the first case, I don't think Python has any specific support for WPAR? Maybe? If not, we shouldn't do anything, if yes, maybe it can be fixed to handle this. It sounds like Ronal may have ran into the first case, or something else entirely. |
May be related: https://bugs.python.org/issue43666 |
There is other, more severe bug in the current code: os.close() is retried after error. Is best case this can cause a "bad file descriptor" error. In worst case it can lead to race condition in multithtread or multiprocessing program. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: