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
cmd/go: indexed packages not invalidated when location of parent go.mod file changes #53586
Comments
Ok, two new failures just occurred on darwin builders: All things considered this is good news, because hopefully additional instrumentation will allow root causing. Unfortunately, this means this really must block the v0.9.0 release; unless we convince ourselves that there is something incorrect about the setup of The increased frequency also makes it more likely that a recent change contributed to these failures. |
Change https://go.dev/cl/414854 mentions this issue: |
Add some additional logging to help debug golang/go#53586 For golang/go#53586 Change-Id: I0574fb01be47b265cd6e412855794bc2cb836dff Reviewed-on: https://go-review.googlesource.com/c/tools/+/414854 gopls-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Robert Findley <rfindley@google.com> Auto-Submit: Robert Findley <rfindley@google.com>
Aha! I only just now noticed the asymmetry between query and result, in the test logs
Note that we're querying for Because the load succeeds, we don't mark these files as unloadable and continue to reload them ad-infinitum. The bug may be in go/packages, or may be in one of the transformations gopls applies. I haven't figured out where the extra 'testmodule' is coming from. |
Ok, I've stared at this for a while, reading the gopls, go/packages, go list, and modindex code. With that said, I haven't made much progress. This appears to be a A few notes:
@bcmills does this type of corruption ring any bells? |
I am looking into modindex to understand a performance problem and will look into this behavior too. |
I wonder if the per-package index needs to include the corresponding module's |
Change https://go.dev/cl/415475 mentions this issue: |
Change https://go.dev/cl/415474 mentions this issue: |
Due to mtime skew we don't index mutable packages with an mtime younger than 2 seconds. In order to test indexed packages reliably, we want to be able to sleep long enough for the files in the package to be cached. (As an alternative we could instead use os.Chtimes to fake old enough timestamps, but sleeping keeps the tests more realistic.) For #53586. Change-Id: I1873f47c55a72d928451593b8c989f0092a557db Reviewed-on: https://go-review.googlesource.com/c/go/+/415474 Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
Change https://go.dev/cl/415514 mentions this issue: |
Ok, the final piece of the puzzle: the packagestest runner actually does invoke the go command before calling the test function, here: And then inside the test function, the go.mod is moved: https://cs.opensource.google/go/x/tools/+/master:internal/lsp/tests/tests.go;l=505;drc=ebc084af8ba794babff1d58912b41608629acd72) So now everything makes sense. |
…umentation The 'path' field was removed in an earlier revision to the format. While auditing the format, I also cleaned up a couple of minor typographical issues. For #53586. Change-Id: I4cd1ce9e970023441c11244428ed2971be1d8138 Reviewed-on: https://go-review.googlesource.com/c/go/+/415514 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Due to mtime skew we don't index mutable packages with an mtime younger than 2 seconds. In order to test indexed packages reliably, we want to be able to sleep long enough for the files in the package to be cached. (As an alternative we could instead use os.Chtimes to fake old enough timestamps, but sleeping keeps the tests more realistic.) For golang#53586. Change-Id: I1873f47c55a72d928451593b8c989f0092a557db Reviewed-on: https://go-review.googlesource.com/c/go/+/415474 Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
The package index format includes the directory relative to the module root. The module root for a given directory can change even if the contents of the directory itself do not (by adding or removing a go.mod file in some parent directory). Thus, we need to invalidate the index for a package when its module root location changes. Fixes golang#53586 (I think). Change-Id: I2d9f4de80e16bce75b3106a2bad4a11d8378d037 Reviewed-on: https://go-review.googlesource.com/c/go/+/415475 Reviewed-by: Russ Cox <rsc@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
…umentation The 'path' field was removed in an earlier revision to the format. While auditing the format, I also cleaned up a couple of minor typographical issues. For golang#53586. Change-Id: I4cd1ce9e970023441c11244428ed2971be1d8138 Reviewed-on: https://go-review.googlesource.com/c/go/+/415514 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
We have two concerning test failures on the builders, which seem to have the same root cause:
darwin-amd64-10_14: https://build.golang.org/log/88d3fe6fbcfe0ba7110aac537e5cdcae51737d4d
openbsd-386-70: https://build.golang.org/log/79c6a4815792817f70a447fecb4557aa33b90ff0
Both of these are concerning because gopls is failing to find package metadata for a file, even after reloading (and apparently successfully loading file data).
It's suprising that files are left orphaned by the initial metadata load (in a typical run, they aren't). It's also suprising that the reloads (via reloadOrphanedFiles) do not correctly result in the requisite file associations. Logging in those test failures indicates that
the loaded packages include the orphaned files, yet they continue to be reloaded(EDIT: my eyes deceived me, the paths don't match! See below).This is likely related to my recent changes to metadata graph building. I'd like to understand this before releasing gopls@v0.9.0. Unfortunately, it seems exceedingly rare; I will see if I can add more instrumentation and reproduce via slowbots.
CC @adonovan
The text was updated successfully, but these errors were encountered: