-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
cmd/go: occasional "failed to cache compiled Go files" when 'go list -compiled' runs in parallel #29667
Comments
Note that while this bug resembles #26794, it occurs when modules aren't involved (GOPATH mode). (I haven't tried to reproduce it in conjunction with modules.) |
Nor can I, and I really have no idea how it would have been fixed. If someone wants to bisect we can at least consider a backport, but given that we can't reproduce it in 1.12, and that it occurs only rarely (and under unusual load) in 1.11, I can't justify putting a lot of effort into tracking it down. |
I'll bisect it. |
Actually, there is no need to bisect it. The issue still occurs as of |
Good to know — thanks for the investigation! CC @jayconrod |
@dominikh thanks for that info. I updated the original description too. |
We are using Go 1.11.2 in our CI system and running parallel jobs that are accessing the same GOCACHE dir by the command:
Recently we implemented to boot additional CI workers on demand. The worker are started with an empty GOCACHE directory. |
golang/go#29667 Co-authored-by: Maria Shaldibina <[email protected]>
This bug has been biting us a lot as we run more and more tools in CI environments which use go/packages. In case it helps other people, the workaround we recently started using is a shim binary that passes its arguments to the I also looked into writing a GOPACKAGESDRIVER tool which would apply the same lockfile-based mutual exclusion around |
I'm still seeing this failure even after upgrading to Go 1.12 -- we're encountering this error when running checks in parallel in a CI environment. The CI environment uses Go 1.12 and the checks are compiled with Go 1.12 as well. The projects use GOPATH mode (it is not a module project). Is there anything that we can do to help with the investigation or fix for this issue? |
@nmiyake If you could describe your CI environment file system, operating system, architecture and any other platform information relevant to file locking, that would be a useful data point. |
This is on an enterprise deployment of CircleCI 2. The Docker image used to run the CI is the official Output of
|
Also seeing this locally as well as on CircleCI (cloud hosted offering). Running on official Go 1.12.1 image. |
Having this same problem. Our CI/CD is running golangci-lint, which underlying is the go list. Strange part is when I ssh into the box, i can run it fine, but when the program runs on its normal workflow it works env is
|
We're seeing this with go 1.11.5 and 1.12.5 (both the official Docker images). After reading @cespare's comment about putting a mutex on #!/bin/sh
set -e
for i in "$@"; do
if [ "$i" = list ]; then
set -o noclobber
while ! echo "$$" >/tmp/go-list-lock; do
sleep 0.25
done
trap 'rm -f /tmp/go-list-lock' EXIT
fi
done
/usr/local/go/bin/go "$@" |
Here's one via the |
Change https://golang.org/cl/188157 mentions this issue: |
Change https://golang.org/cl/188020 mentions this issue: |
Change https://golang.org/cl/188021 mentions this issue: |
An apparent typo caused us to re-check size instead. Updates #29667 Change-Id: Icc1fb9cef1ba77b8490c8fbe6c343be06ff48d8d Reviewed-on: https://go-review.googlesource.com/c/go/+/188020 Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
Since the cache has been required since Go 1.12, also remove redundant checks for a nil cache. Updates #29127 Updates #29667 Change-Id: Ibc59b659306a4eef2d4f0e3d0b651986d6cf84ad Reviewed-on: https://go-review.googlesource.com/c/go/+/188021 Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
What version of Go are you using (
go version
)?Go 1.11.4
Does this issue reproduce with the latest release?
It does not reproduce with Go 1.12beta1.It reproduces at tip at a somewhat lower rate. See @dominikh's comment, below.What operating system and processor architecture are you using (
go env
)?linux/amd64
What did you do?
@dominikh wrote a small reproducer: https://play.golang.org/p/ghOtMwBnGu7
It may take a few runs to fail. Clean out your build cache or use GOCACHE=/tmp/empty to make it more reliably fail.
What did you expect to see?
Calling
go list
in parallel should succeed.What did you see instead?
I think this happens only when
-compiled
is provided togo list
(which is new in Go 1.11?)The context in which this comes up is multiple tools running
golang.org/x/tools/go/packages.Load
at the same time. I believe the issue is ingo list
but possibly the bug (or at least the workaround) should be in golang.org/x/tools/go/packages.I also believe this is much more likely to happen with an empty GOCACHE. We've mainly been seeing this our CI environment. github.com/google/wire has also been seeing this in Travis: google/wire#66.
The effects of this issue tend to be pretty far away from the
go list
invocation. We've run into it via staticcheck (http://staticcheck.io/) as well as our own go/packages-using code.I can't get this to reproduce in 1.12beta1. It would be helpful if someone can find the CL that fixed it. I think it would also be valuable if the fix could be backported to Go 1.11 in the meantime.(It does reproduce at tip.)The ecosystem is rapidly converging on the new,
go list
-based way of writing tooling (typically via go/packages) so I expect this will arise often./cc @bcmills @dominikh @zombiezen @ianthehat
The text was updated successfully, but these errors were encountered: