Skip to content
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

x/tools/gopls: rapid changes cause errors, context cancellation #32899

Open
stamblerre opened this issue Jul 2, 2019 · 5 comments

Comments

Projects
None yet
4 participants
@stamblerre
Copy link
Contributor

commented Jul 2, 2019

Forked from #32667 (comment).

I'm seeing this in a module context. In my situation, there are a number of relatively rapid changes to certain files (a code generator is the source of the changes, but the changes are notified to gopls via didChange notifications).

I first see a number of lines like:

unable to check package for file:///path/to/file.go: context canceled

I also see a number of lines like:

failed to deliver diagnostic for file:///path/to/file.go (will retry): context canceled

Then I see a number of lines like:

unable to check package for file:///path/to/file.go: loadParseTypeCheck: no package found for /path/to/file.go

I also see a number of lines like:

file:///path/to/file.go is not part of a package

I don't yet have a repro for this.


What version of Go are you using (go version)?

$ go version
go version go1.12.6 linux/amd64
$ go list -m golang.org/x/tools
golang.org/x/tools v0.0.0-20190618233249-04b924abaa25
$ go list -m golang.org/x/tools/gopls
golang.org/x/tools/gopls v0.0.0-20190618233249-04b924abaa25

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN="/home/myitcv/gostuff/src/github.com/myitcv/govim/cmd/govim/.bin"
GOCACHE="/home/myitcv/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/myitcv/gostuff"
GOPROXY=""
GORACE=""
GOROOT="/home/myitcv/gos"
GOTMPDIR=""
GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/myitcv/gostuff/src/github.com/myitcv/govim/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build453321011=/tmp/go-build -gno-record-gcc-switches"

FWIW this was also an issue with:

golang.org/x/tools v0.0.0-20190612231717-10539ce30318
golang.org/x/tools/gopls v0.1.0
@myitcv

This comment has been minimized.

Copy link
Member

commented Jul 2, 2019

Per discussions with @stamblerre and @ianthehat on Slack, I suspect the issue here is something along the lines of:

  • lots of didOpen/didChange notifications because of the code generation
  • gopls cancels the handling/something of one/more of these notifications because of #reasons (hence the context canceled messages)
  • this leaves gopls in a bad state for the file in question
  • we get the subsequent error messages:
/path/to/file is not part of a package
@muirrn

This comment has been minimized.

Copy link

commented Jul 2, 2019

This change fixed a similar issue. Are you still seeing this failure?

@myitcv

This comment has been minimized.

Copy link
Member

commented Jul 3, 2019

I still see the errors mentioned in #32899 (comment) as of fb37f6ba8261. The tricky thing is, this is very much a timing related issue... so I can't reproduce it reliably.

I can't test much beyond that because https://go-review.googlesource.com/c/tools/+/184257 appears to have introduced some sort of bug/issue whereby trying to call goimports (i.e. the code action) after the steps above causes gopls to hang (or it was hung up before I tried to call it, not sure).

Stack trace of that hang:

https://gist.github.com/myitcv/9d1f257c32e1cddde1589c63d34c9a0e

@stamblerre

This comment has been minimized.

Copy link
Contributor Author

commented Jul 3, 2019

Oh, I expect you are seeing the issues fixed by @muirrn here: https://go-review.googlesource.com/c/tools/+/184880.

@myitcv

This comment has been minimized.

Copy link
Member

commented Jul 3, 2019

Thanks, yes that did fix the hang. I'll monitor 504de27b367a and feedback here if I do/don't see any occurrences of the context cancellation issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.