-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: go mod tidy
cache entry races with file system changes
#40269
Comments
FYI - just updated the update pull request to include the latest commits as well, now at 6ddee64 - govim/govim#908 |
A further three flakes as part of the merge of upgrading to golang/tools@6ddee64: https://github.com/govim/govim/actions/runs/172568134 |
Thanks for the report. I'm a bit confused by the error messages here:
How does Worth noting that we have an equivalent test in the |
The tests uses Rogers goproxytest fork - github.com/rogpeppe/go-internal/goproxytest so the module is defined as:
|
Regarding the error messages you see, I had another failure log opened and it didn't show there. I also opened up the gopls log linked from govim/govim#909 (comment) and no such entry there either. I'm not sure that it has anything to do with the flakes. |
How long do the tests wait for the diagnostics? Is the |
Basically, |
Using the
and then the rest of the log trying to see if |
Comparing the log above against a test where it works, both of them has the same not working:
working:
and for reference, when it works the
|
It wasn't obvious in my previous comments; the test waits 30 seconds for the diagnostics to complete so that shouldn't be an issue. |
Ok, thanks for the clarifications. I will try to write a
So, from what I can tell, we have:
Obviously |
To reproduce this, I think need information about the file changes that happen on disk (how is the file text edited?). What state are the files in when the code action and formatting requests happen? |
I'm not surprised by the file events, even if I can't explain from the top of my head why we get a delete/create pair. File watching is a mess.. The sequence looks the same both when the test pass and fail, and there hasn't been any changes recently on the Just some details on how events are mapped on Linux, where the flakes appear:
The file isn't edited at all, it's just opened up in a running editor, and then saved back to disk. That's it. Recap with the same log as before:
When the test fails it waits here for 30 seconds for diagnostics, as in the log linked. Otherwise The order of events is the same when it works and when it doesn't. |
Thanks for the detailled analysis, @leitzler. @stamblerre - I think the file change events are a red herring because the file is open in editor (and
I think it's probably a combination of how Vim writes files in certain situations and file watching. Both are a mess, but per my comment above, I think these details are actually irrelevant in this case.
This point is also relevant. |
This is true, but the In any case, it would be really good to know what the exact file content changes are, because then I can reproduce this consistently with a |
The content never change. Is it something missing in my comments above? Or some logging that we can activate that would help? |
I'm wondering about the DidChangeWatchedFiles notifications, since they don't have content associated with them. When the file is created again, does it have content in it or is it empty? What is the content that's written to the file in the two DidChangeWatchedFiles notifications that are changes (not creation/deletion)? Or is it just always the same? |
Always the same, the remove/create events are either an artifact from gvim or the filesystem watcher. It's just the same file with the same content through the entire test. |
Change https://golang.org/cl/243537 mentions this issue: |
I think I caught the issue in https://golang.org/cl/243537. I've marked it only as "Updates" because I can't be sure that was the only issue, so once it's merged I'll follow up to see if that fixed the issue. |
Actually, this race exposes a deeper issue, which is that the way we cache The best solution I can think of right now is to check if any state has changed on-disk before we run Yet another case that could be fixed with #39958... |
Previously, we only updated the opened file's overlay, but not the snapshot. This meant that the snapshot was still operating with stale data. Invalidating the snapshot creates a new snapshot with the correct set of overlays. The test is skipped because it will flake until we have a better caching strategy for `go mod tidy` results. Updates golang/go#40269 Change-Id: Ia8d1ae75127a1d18d8877923e7a5b25b7bd965ac Reviewed-on: https://go-review.googlesource.com/c/tools/+/243537 Run-TryBot: Rebecca Stambler <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]>
https://golang.org/cl/243537 addressed some of the issues I noticed while debugging this test, but it doesn't resolve the problem. I think the next step here will be to add an API to the cache that allows us to delete entries, so that we can check if the workspace state changed between the time we cached and the time we ran the command. I think that will likely happen after @heschik's changes to the cache, so in the meantime, I am hoping this is enough of an edge case that it shouldn't be a critical concern. Setting v1.0.0 as the milestone, as I think it would still be best to have this in by then. |
go mod tidy
race with file system changes
go mod tidy
race with file system changesgo mod tidy
cache entry races with file system changes
For completeness we are still seeing this as of 6467de6 |
Considering that the approach suggested in #40269 (comment) would mitigate but not correct the problem, it's probably not actually worth requiring it for 1.0. I'd be very surprised if any users actually saw this issue in practice. |
Change https://go.dev/cl/420718 mentions this issue: |
I believe the races described in the issue have been fixed: we should invalidate mod tidy results on any metadata change. If this invalidation doesn't work due to a race, we want to know about it. Update the test to wait for file-related events to complete before removing files, in an attempt to avoid windows file-locking issues. For golang/go#40269 For golang/go#53878 Change-Id: I91f0cb4969851010b34904a0b78ab9bd2808f92e Reviewed-on: https://go-review.googlesource.com/c/tools/+/420718 Run-TryBot: Robert Findley <[email protected]> gopls-CI: kokoro <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Suzy Mueller <[email protected]>
We now correctly invalidate No failures since re-enabling. |
What version of Go are you using (
go version
)?What did you do?
After updating x/tools & gopls from 0cc1aa72b347 to f2c07d7d8ec1 in
govim
we started to see flakes in our tempmodfile tests:Essence of the test case that runs with
tempModfile
set:Full logs from gopls is included in govim/govim#909.
The text was updated successfully, but these errors were encountered: