Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
x/tools/internal/lsp/regtest: closing workspace sometimes fails on Windows #38490
Due to Windows' default file locking behavior, and the fact that gopls often shells out to the
In https://golang.org/cl/228231 I try to avoid this by deferring workspace cleanup until the end of the regtest test suite, but this is just a workaround and may break in the future. Also, this doesn't fix the problem for other test suites, such as
One possible solution is to simply retry this cleanup until it succeeds or times out, but this is bound to be problematic. In testing it can take anywhere from 10ms to 1s for such a retry to succeed, and the retry behavior introduces a bunch of complexity that should be unnecessary.
A better solution may be related to something else we've discussed: ensure that all work done on behalf of gopls is captured in a span, and expose an API that can signal when gopls work has completed (for a workspace? for a snapshot?). If that is not sufficient, we may want to extend this to a control plane that allows (among other things) manually terminating any processes associated with a workspace.
Closing the workspace has frequently been failing on Windows, due to file locks held by the go command. This change makes several tests more careful to check errors when closing resources, and defers closing the regtest workspaces until the entire test suite completes, at which point it is much more likely that closing the workspace will succeed. If this change results in test flakes on Windows, we should temporarily demote errors in regtest.Runner.Close to a t.Log. Updates golang/go#38490 Change-Id: Ibd2f7dd0e0e2faecfa0ca8c60237fc72e64f6719 Reviewed-on: https://go-review.googlesource.com/c/tools/+/228231 Run-TryBot: Robert Findley <email@example.com> TryBot-Result: Gobot Gobot <firstname.lastname@example.org> Reviewed-by: Rebecca Stambler <email@example.com>
For easier debugging (and less cruft if regtests are ctrl-c'ed), root all regtest sandboxes in a common directory. This also tries one last time to clean up the directory, and fails on an error. This might be flaky on windows, but hasn't been so far... Also give regtest sandboxes names derived from their test name. Updates golang/go#39384 Updates golang/go#38490 Change-Id: Iae53c29e75f5eb2b8d938d205fbeb463ffc82eb2 Reviewed-on: https://go-review.googlesource.com/c/tools/+/240059 Run-TryBot: Robert Findley <firstname.lastname@example.org> TryBot-Result: Gobot Gobot <email@example.com> Reviewed-by: Rebecca Stambler <firstname.lastname@example.org>
This is in fact still a problem after the above change: https://storage.googleapis.com/go-build-log/85afa2eb/windows-amd64-2016_3d74be50.log
Need to make this fail silently again. CC @heschik
Due to Windows' default file locking and the fact that regtests shell out to the go command, cleanup sometimes fails. This is causing trybot flakes, increasingly as of late. Since the tempdir will eventually be cleaned up on the trybots anyway, don't fail on windows. For golang/go#38490 Change-Id: I136d97143baba1d98777db51daa062cf0e42e33e Reviewed-on: https://go-review.googlesource.com/c/tools/+/258315 Trust: Robert Findley <email@example.com> Run-TryBot: Robert Findley <firstname.lastname@example.org> gopls-CI: kokoro <email@example.com> TryBot-Result: Go Bot <firstname.lastname@example.org> Reviewed-by: Rebecca Stambler <email@example.com>