-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: 'Access is denied' when renaming module cache directory [1.13 backport] #37802
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
Labels
Milestone
Comments
This was referenced Mar 11, 2020
Change https://golang.org/cl/223146 mentions this issue: |
Approved. This is a serious issue without a reasonable workaround. |
Closed by merging 2f6dd92 to release-branch.go1.13. |
gopherbot
pushed a commit
that referenced
this issue
Apr 7, 2020
Currently, we extract module zip files to temporary directories, then atomically rename them into place. On Windows, this can fail with ERROR_ACCESS_DENIED if another process (antivirus) has files open before the rename. In CL 220978, we repeated the rename operation in a loop over 500 ms, but this didn't solve the problem for everyone. A better solution will extract module zip files to their permanent locations in the cache and will keep a ".partial" marker file, indicating when a module hasn't been fully extracted (CL 221157). This approach is not safe if current versions of Go access the module cache concurrently, since the module directory is detected with a single os.Stat. In the interim, this CL makes two changes: 1. Flaky file system operations are repeated over 2000 ms to reduce the chance of this error occurring. 2. cmd/go will now check for .partial files created by future versions. If a .partial file is found, it will lock the lock file, then remove the .partial file and directory if needed. After some time has passed and Go versions lacking this CL are no longer supported, we can start extracting module zip files in place. Updates #37802 Change-Id: I467ee11aa59a90b63cf0e3e761c4fec89d57d3b6 Reviewed-on: https://go-review.googlesource.com/c/go/+/221820 Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> (cherry picked from commit 093049b) Reviewed-on: https://go-review.googlesource.com/c/go/+/223146
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Based on #36568.
CL 221820 mitigates #36568, an issue where antivirus (or a similar program) prevents modules from being extracted into the module cache. That CL makes two changes:
os.Rename
(the operation that fails) is re-attempted multiple times over 2000 ms. This should make the error less frequent, but doesn't eliminate it entirely.os.Rename
.CL 221157 is the proper solution for this problem, but it can't be enabled yet because older versions of the Go command (1.14 and earlier) assume that if a module directory is present, it is fully extracted and ready to use. So if Go 1.14 and 1.15 access the same module directory concurrently, 1.14 might see a partially extracted module. CL 221820 prevents that from happening.
The flag in CL 221157 can be flipped safely when 1.14 and older versions are no longer supported and no longer in use. That would probably be true for 1.17.
I'd like to speed up the migration by backporting CL 221820 to 1.14 and possibly 1.13. That would allow us to flip the flag in 1.16.
The text was updated successfully, but these errors were encountered: