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: TestResolveImportCycle is flaky #46773

Closed
findleyr opened this issue Jun 15, 2021 · 9 comments
Closed

x/tools/gopls: TestResolveImportCycle is flaky #46773

findleyr opened this issue Jun 15, 2021 · 9 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. Testing An issue that has been verified to require only test changes, not just a test failure. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@findleyr
Copy link
Contributor

This test was added newly in https://golang.org/cl/326589, and appears to be flaky.

Sample failure:
https://build.golang.org/log/1919547c028c2fd16c892afb37ab336de61675ae

It may be that the fix for import cycle resolution is racy.

@findleyr findleyr added Testing An issue that has been verified to require only test changes, not just a test failure. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jun 15, 2021
@findleyr findleyr self-assigned this Jun 15, 2021
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Jun 15, 2021
@gopherbot gopherbot added this to the Unreleased milestone Jun 15, 2021
@bcmills
Copy link
Contributor

bcmills commented Jun 15, 2021

Ah, that explains the TryBot failure in https://storage.googleapis.com/go-build-log/011d0a8d/linux-amd64_e6bc22ff.log (CL 328231)!

@gopherbot
Copy link

Change https://golang.org/cl/328369 mentions this issue: gopls/internal/regtest: skip the flaky TestResolveImportCycle

gopherbot pushed a commit to golang/tools that referenced this issue Jun 16, 2021
Also improve the description of the failing expectations.

Updates golang/go#46773

Change-Id: I9465de8a5005bb7ee719a536f8550afc54bd6044
Reviewed-on: https://go-review.googlesource.com/c/tools/+/328369
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
@suzmue suzmue modified the milestones: Unreleased, gopls/v0.7.1 Jun 21, 2021
@LeGEC
Copy link

LeGEC commented Jun 29, 2021

A number of tests seem to fail with the error : err:context deadline exceeded (see logs mentioned in the current issue, or #46930 or any of the logs I could inspect in #46183).

In the mentioned logs : all tests that fail mention that some test took longer than 20s, which is the default context timeout for regtest.Run()

# example from the log mentioned in this issue :
   --- FAIL: TestResolveImportCycle/experimental_workspace_module (20.00s)
   
# other issues mention other failing tests, with a run time of ~20s and something

When inspecting these tests individually (I ran TestResolveImportCycle and TestProgressBarErrors on my machine), I wasn't able to trigger a context deadline exceeded issue when running repeatedly the test sequentially :

# I wasn't able to trigger the error this way :
for i in {1..100}; do
    go test -count=1 -run TestResolveImportCycle golang.org/x/tools/gopls/internal/regtest/diagnostics
done

However I was able to trigger the error when running several times the tests in parallel :

# this triggered the error, not always but with some non 0 probability :
for i in {1..10}; do
    go test -count=1 -run TestResolveImportCycle golang.org/x/tools/gopls/internal/regtest/diagnostics &  # <- in parallel
done
wait

# this also highlighted the TestProgressBarErrors bug

it looks like, in some case, the runner started by internal/lsp/regtest/Runner.Run just gets stuck.

haven't dug deeper yet

@findleyr
Copy link
Contributor Author

findleyr commented Jun 29, 2021

@LeGEC thanks for looking into this. I suspect due to the flake frequency of this particular test that there is an underlying race in gopls itself -- haven't had time to look into it yet. Other regtest failures are simply due to resource contention on the builders. The gopls regtests spawn a lot of subprocesses and are very memory intensive, which affects various builders differently. I try to be conservative and disable, shard, or rewrite tests as soon as they prove to be flaky, but hesitate to disable the regtests entirely when run with -short, because they catch a lot of bugs.

Are you just looking into this to help out, or are the regtests causing you problems in some way? Either way, thanks again.

@LeGEC
Copy link

LeGEC commented Jun 29, 2021

@findleyr : I was picking some issues just as a way to start looking into gopls codebase.

These tests do not cause specific issues on my side.

@gopherbot
Copy link

Change https://golang.org/cl/333289 mentions this issue: internal/lsp/regtest: allow for unsent diagnostics in TestResolveImportCycle

@findleyr
Copy link
Contributor Author

findleyr commented Jul 9, 2021

It appears the failure mode fixed by CL 333289 is not the only one. Sample:
https://build.golang.org/log/b9e55f800f2b3728fd22e9322b67eeb780ceb2f4

@gopherbot
Copy link

Change https://golang.org/cl/333510 mentions this issue: internal/lsp/regtest: fix a panic TestResolveImportCycle

gopherbot pushed a commit to golang/tools that referenced this issue Jul 9, 2021
CL 333289 introduced a panic, which was subsequently suppressed in test
error output due to the deferred t.Fatal (an interesting gotcha that I
honestly wasn't aware of).

Fix both the panic, and the suppression of regtest panics.

Also fix the regtest editor shutdown to run on a detached context, so
that shutdown doesn't fail for tests that have timed out.

For golang/go#46773

Change-Id: I080a713ae4cd4651476d8b4aab1d2291754a4f5a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/333510
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
@findleyr
Copy link
Contributor Author

findleyr commented Jul 23, 2021

No failures since July 9th (when the above CL was submitted). Closing.

@golang golang locked and limited conversation to collaborators Jun 23, 2023
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. Testing An issue that has been verified to require only test changes, not just a test failure. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants