]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.13] cmd/go: make module zip extraction more robust
authorJay Conrod <jayconrod@google.com>
Fri, 28 Feb 2020 21:31:19 +0000 (16:31 -0500)
committerAndrew Bonventre <andybons@golang.org>
Tue, 7 Apr 2020 20:06:16 +0000 (20:06 +0000)
commit2f6dd92c1ef5a202a3d13ff16254d2a3d7b03c02
treec8a4a192cdb9e34455a080d54694ddfe7ee19dc8
parentb79c36dc9949177aa6e2e33fe5af61d4461676a4
[release-branch.go1.13] cmd/go: make module zip extraction more robust

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 093049b3709eda7537ece92a2991918cf53782d6)
Reviewed-on: https://go-review.googlesource.com/c/go/+/223146
src/cmd/go/internal/modcmd/verify.go
src/cmd/go/internal/modfetch/cache.go
src/cmd/go/internal/modfetch/fetch.go
src/cmd/go/internal/modload/build.go
src/cmd/go/internal/robustio/robustio_windows.go
src/cmd/go/testdata/script/mod_download_partial.txt [new file with mode: 0644]