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: context cancellation errors in type-checking #33678

Closed
zikaeroh opened this issue Aug 16, 2019 · 6 comments
Closed

x/tools/gopls: context cancellation errors in type-checking #33678

zikaeroh opened this issue Aug 16, 2019 · 6 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@zikaeroh
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

What did you do?

Edit my code normally, adding functions, imports, etc.

What did you expect to see?

Completion, diagnostics, etc, continue to work.

What did you see instead?

After a few edits, I'm stuck with "work queue is full" and am forced to reload the editor.

Build info

golang.org/x/tools/cmd/gopls v0.1.3-cmd.gopls
    golang.org/x/tools@v0.0.0-20190815235612-5b08f89bfc0c h1:7eYQMBMvMxbxtNK/jCq9umo/V/QiO5CLoIzIpSYM1i4=
    golang.org/x/sync@v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
    golang.org/x/xerrors@v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc=

Go info

go version go1.12.8 linux/amd64

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jake/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/jake/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/jake/zikaeroh/hortbot/hortbot/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-build700267818=/tmp/go-build -gno-record-gcc-switches"

Some logs:

[Info  - 9:28:51 PM] 2019/08/15 21:28:51 637.47427ms for GOROOT=/usr/lib/go GOPATH=/home/jake/go GO111MODULE= PWD=/home/jake/zikaeroh/hortbot/hortbot go "list" "-e" "-json" "-compiled=true" "-test=true" "-export=false" "-deps=true" "-find=false" "--" "/home/jake/zikaeroh/hortbot/hortbot/internal/bot", stderr: <<>>

[Info  - 9:28:51 PM] 2019/08/15 21:28:51 go/packages.Load
	packages = 2
[Info  - 9:28:51 PM] 2019/08/15 21:28:51 go/packages.Load
	package = github.com/hortbot/hortbot/internal/bot
	files = [/home/jake/zikaeroh/hortbot/hortbot/internal/bot/access_level.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/accesslevel_string.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/actions.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/autoreplies.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/bot.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/builtin_commands.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_admin.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_autoreplies.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_command.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_filters.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_fun.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_lastfm.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_levels.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_list.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_management.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_moderation.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_quote.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_raffle.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_random.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_repeat.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_schedule.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_settings.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_steam.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_twitch.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_var.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/correlation.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/custom_command.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/deps.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/filters.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/handle.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/helpers.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/interfaces.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/rdb.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/repeat.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/session.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/sessiontype_string.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/testing.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/var.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/access_level_test.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/export_test.go]
[Info  - 9:28:51 PM] 2019/08/15 21:28:51 go/packages.Load
	package = github.com/hortbot/hortbot/internal/bot
	files = [/home/jake/zikaeroh/hortbot/hortbot/internal/bot/access_level.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/accesslevel_string.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/actions.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/autoreplies.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/bot.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/builtin_commands.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_admin.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_autoreplies.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_command.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_filters.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_fun.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_lastfm.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_levels.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_list.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_management.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_moderation.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_quote.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_raffle.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_random.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_repeat.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_schedule.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_settings.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_steam.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_twitch.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_var.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/correlation.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/custom_command.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/deps.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/filters.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/handle.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/helpers.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/interfaces.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/rdb.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/repeat.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/session.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/sessiontype_string.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/testing.go /home/jake/zikaeroh/hortbot/hortbot/internal/bot/var.go]
2019/08/15 21:28:51 failed to check package: check: context canceled
2019/08/15 21:28:51 failed to check package: check: context canceled
2019/08/15 21:28:51 failed to compute diagnostics: no CheckPackageHandles for file:///home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_twitch.go
	file = file:///home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_twitch.go
2019/08/15 21:28:51 failed to check package: check: context canceled
2019/08/15 21:28:51 failed to check package: check: context canceled
2019/08/15 21:28:51 failed to deliver diagnostic for (will not retry): Parse: context canceled
	file = file:///home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_twitch.go
[Error - 9:28:51 PM] 2019/08/15 21:28:51 failed to deliver diagnostic for (will not retry): Parse: context canceled
	file = file:///home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_twitch.go
[Error - 9:28:51 PM] 2019/08/15 21:28:51 failed to check package: check: context canceled
[Error - 9:28:51 PM] 2019/08/15 21:28:51 failed to check package: check: context canceled
[Error - 9:28:51 PM] 2019/08/15 21:28:51 failed to compute diagnostics: no CheckPackageHandles for file:///home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_twitch.go
	file = file:///home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_twitch.go
[Error - 9:28:51 PM] 2019/08/15 21:28:51 failed to check package: check: context canceled
[Error - 9:28:51 PM] 2019/08/15 21:28:51 failed to check package: check: context canceled
[Info  - 9:28:51 PM] 2019/08/15 21:28:51 no completions found
	At = {0xc000226700 13154077 13154077}
	Failure = this is a definition, of const followAut invalid type
2019/08/15 21:28:51 failed to check package: check: context canceled
[Error - 9:28:51 PM] 2019/08/15 21:28:51 failed to check package: check: context canceled
2019/08/15 21:28:51 failed to check package: check: context canceled
2019/08/15 21:28:51 failed to deliver diagnostic (will retry): Parse: context canceled
	file = file:///home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_twitch.go
[Error - 9:28:51 PM] 2019/08/15 21:28:51 failed to check package: check: context canceled
[Error - 9:28:51 PM] 2019/08/15 21:28:51 failed to deliver diagnostic (will retry): Parse: context canceled
	file = file:///home/jake/zikaeroh/hortbot/hortbot/internal/bot/cmd_twitch.go
2019/08/15 21:28:51 failed to check package: check: context canceled
[Error - 9:28:51 PM] 2019/08/15 21:28:51 failed to check package: check: context canceled
2019/08/15 21:28:51 failed to check package: check: context canceled
2019/08/15 21:28:51 failed to check package: check: context canceled
2019/08/15 21:28:51 failed to check package: check: context canceled
work queue is full
work queue is full
work queue is full
work queue is full
work queue is full
work queue is full
work queue is full
work queue is full
@gopherbot gopherbot added this to the Unreleased milestone Aug 16, 2019
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Aug 16, 2019
@zikaeroh
Copy link
Contributor Author

Perhaps this is the same as #33531 (but I'm unsure).

@stamblerre
Copy link
Contributor

This is an issue I just introduced with CL 185438. I'm in the process of some pretty large changes, so things may be a bit unstable on master right now. That said, it seems like what's happening here is that we are propagating context cancellation errors from type-checking. I'll try to investigate this a bit further.

@stamblerre stamblerre added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 16, 2019
@stamblerre stamblerre changed the title x/tools/gopls: Stops working after a few edits with "work queue is full" x/tools/gopls: context cancellation errors in type-checking Aug 16, 2019
@muirdm
Copy link

muirdm commented Aug 16, 2019

Maybe the CL you mentioned reintroduced the problem where we cache the context.Canceled error in the package cache and it gets stuck that way indefinitely. Can we make it never cache the package on type checker errors like before?

Also, it seems like https://go-review.googlesource.com/c/tools/+/190412 maybe have broken some spots checking explicitly for the context.Canceled error. Perhaps we should use the "%w" error wrapping verb and the checking code should use errors.Is(err, context.Canceled) instead?

@gopherbot
Copy link

Change https://golang.org/cl/190601 mentions this issue: internal/lsp: unlabel context, log errors when canceled

gopherbot pushed a commit to golang/tools that referenced this issue Aug 20, 2019
Updates golang/go#33678

Change-Id: I844d6599a3e0ae9594dda1abaebe938402b65822
Reviewed-on: https://go-review.googlesource.com/c/tools/+/190601
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
@gopherbot
Copy link

Change https://golang.org/cl/192719 mentions this issue: internal/lsp: use memoize store's context when type checking

gopherbot pushed a commit to golang/tools that referenced this issue Sep 4, 2019
The memoize store passes a detached context to the value getter
function. This is important since if the value getter experiences a
context cancellation it will end up caching context.Canceled, which
you never want. When type checking, we were ignoring the detached
context and using the "real" request context. This would cause the
context.Canceled error to get cached and continue popping up in
various situations.

Fix by swapping the importer's context to the detached context. It is
a little messy since the importer stores the context as a field. I
added a defer to restore the original context since it doesn't seem
correct to let the detached context escape the memoize function.

Updates golang/go#33678

Change-Id: I20dd466b0072ac2e856adbe993364f77e93ab054
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192719
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Sep 12, 2019
@stamblerre
Copy link
Contributor

I believe that these errors should no longer be an issue, as a lot has changed in the gopls caching and type-checking mechanisms has changed since then.

@golang golang locked and limited conversation to collaborators Nov 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants