Go 1.11 module cache not safe for concurrent use?

793 views
Skip to first unread message

Maxim Khitrov

unread,
Aug 28, 2018, 11:01:43 AM8/28/18
to golang-nuts
I'm running into non-deterministic errors when I try to build multiple
binaries from the same module with goreleaser in a CI/CD system. Here
are some examples:

go: finding github.com/pkg/browser v0.0.0-20170505125900-c90ca0c84f15
go: github.com/pkg/bro...@v0.0.0-20170505125900-c90ca0c84f15: git
fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in
/go/pkg/mod/cache/vcs/8755ee3fe34afbf0e42bd94de4ff233c0a12a60e9ddcc7a72c38f16620d3eebf:
chdir /go/pkg/mod/cache/vcs/8755ee3fe34afbf0e42bd94de4ff233c0a12a60e9ddcc7a72c38f16620d3eebf:
no such file or directory

go: github.com/davecgh/go-...@v1.1.1: git remote add origin
https://github.com/davecgh/go-spew in
/go/pkg/mod/cache/vcs/b9a4b9bbdb4a59723f2348415ad7ffda91568455a1cfd92e97976132bdfbaf57:
exit status 128:
fatal: remote origin already exists.

go: github.com/pmezard/go-di...@v1.0.0: unknown revision v1.0.0

go: error loading module requirements

If I run 'go mod download' before the build, everything works fine, so
I believe that this problem is caused by goreleaser starting multiple
parallel builds with an empty module cache. I've tested this several
times now by removing pkg/mod and GOCACHE directories.

My question is whether it should be possible to do so or if this is
just a known limitation of how the module cache works? The following
issue suggests that GOCACHE is safe for concurrent use, but I couldn't
find information on the module cache:

https://github.com/golang/go/issues/26677

-Max

Bryan Mills

unread,
Sep 13, 2018, 2:39:21 PM9/13/18
to golang-nuts
The module cache and the build cache are separate entities.

The build cache is safe for concurrent use. The module cache is not (yet),¹ but you can pre-populate it by running go mod download.



On Tuesday, August 28, 2018 at 11:01:43 AM UTC-4, Maxim Khitrov wrote:
I'm running into non-deterministic errors when I try to build multiple
binaries from the same module with goreleaser in a CI/CD system. Here
are some examples:

go: finding github.com/pkg/browser v0.0.0-20170505125900-c90ca0c84f15
go: github.com/pkg/bro...@v0.0.0-20170505125900-c90ca0c84f15: git
fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in
/go/pkg/mod/cache/vcs/8755ee3fe34afbf0e42bd94de4ff233c0a12a60e9ddcc7a72c38f16620d3eebf:
chdir /go/pkg/mod/cache/vcs/8755ee3fe34afbf0e42bd94de4ff233c0a12a60e9ddcc7a72c38f16620d3eebf:
no such file or directory

go: github.com/davecgh/go-spew@v1.1.1: git remote add origin
https://github.com/davecgh/go-spew in
/go/pkg/mod/cache/vcs/b9a4b9bbdb4a59723f2348415ad7ffda91568455a1cfd92e97976132bdfbaf57:
exit status 128:
    fatal: remote origin already exists.

go: github.com/pmezard/go-difflib@v1.0.0: unknown revision v1.0.0
Reply all
Reply to author
Forward
0 new messages