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

cmd/go: "cannot access the file because it is being used by another process" flakes on Windows #71112

Open
FiloSottile opened this issue Jan 3, 2025 · 11 comments
Labels
Bug Issues describing a bug in the Go implementation. GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows
Milestone

Comments

@FiloSottile
Copy link
Contributor

FiloSottile commented Jan 3, 2025

#!watchflakes
default <- pkg == "cmd/go" && test == "TestScript" && `The process cannot access the file because it is being used by another process.`

I am getting a lot of these flakes on the Windows TryBots, three just in the last day, and they are getting kinda tedious.

=== RUN   TestScript
vcs-test.golang.org rerouted to http://127.0.0.1:49858
https://vcs-test.golang.org rerouted to https://127.0.0.1:49859
go test proxy running at GOPROXY=http://127.0.0.1:49860/mod
    script_test.go:54: remove C:\b\s\w\ir\x\t\cmd-go-test-3977021774\vcstest3518644654\auth\or401\.access: The process cannot access the file because it is being used by another process.

https://ci.chromium.org/ui/p/golang/builders/try/gotip-windows-amd64/b8726767142354977169/overview
https://ci.chromium.org/ui/p/golang/builders/try/gotip-windows-386/b8726850438465216129/overview
https://ci.chromium.org/ui/p/golang/builders/try/gotip-windows-amd64/b8726734771386763217/overview

AFAICT, there is no tracking issue, just a sea of TestScript testflakes issues, with this specific message showing up about 3 weeks ago in #66337, which has a catch-all pkg == "cmd/go" && test == "TestScript" testflakes definition.

#66337 (comment)
#66337 (comment)
#66337 (comment)
#66337 (comment)

@FiloSottile
Copy link
Contributor Author

Aside from fixing the specific issue, is there something that could be improved in flakes monitoring? Maybe testflakes could also monitor TryBot reruns for the same commit? Or it could be more granular for large tests such as TestScript?

@dmitshur dmitshur added OS-Windows NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels Jan 3, 2025
@dmitshur dmitshur added this to the Backlog milestone Jan 3, 2025
@ianlancetaylor
Copy link
Member

CC @golang/windows @matloob @samthanawalla

@dmitshur
Copy link
Contributor

dmitshur commented Jan 3, 2025

AFAICT, there is no tracking issue, just a sea of TestScript testflakes issues, with this specific message showing up about 3 weeks ago in #66337, which has a catch-all pkg == "cmd/go" && test == "TestScript" testflakes definition.

The Watchflakes wiki page suggests:

The newly created issue’s pattern is often too broad and should be edited to make it more specific to the actual failure. Sending a failure to the lowest-numbered matching issue ensures that creating a broad default pattern for a new failure does not “steal” failures from earlier issues, nor does it spam the new issue with unrelated failures in the same test that are already separately tracked.

Watchflakes places newly created issues in the Test Flakes project and adds the NeedsInvestigation label. These issues start out with no status (not Active, not Done). Issues with no status need to be inspected by a person, who should usually refine the pattern to capture the salient information about the failure. Issues that have been checked can then be moved to Active. [...]

The pattern in #66337 is definitely broad, and it hasn't progressed beyond the NeedsInvestigation / no status state yet. If it's narrowed down to something that doesn't match these errors, then it creates room for this failure mode to be tracked in another issue.

is there something that could be improved in flakes monitoring? Maybe testflakes could also monitor TryBot reruns for the same commit? [...]

I suggest filing a separate x/build/cmd/watchflakes issue for that change. It would need someone interested to find time and work on it, but it's more likely to be forgotten as part of this issue.

(Edit: It's useful to know which of the flaky tests are contributing most to development friction and reducing velocity, so thanks for reporting this.)

@FiloSottile
Copy link
Contributor Author

One more, https://ci.chromium.org/ui/p/golang/builders/try/gotip-windows-amd64/b8726732876617875553/overview.

(Sorry to whine, but I had changes fall through the cracks because I AutoSubmit+1'd them after the Code-Review+2, and instead of making their journey through go.dev/s/needs-review and to submission, got stuck on flakes.)

@ianlancetaylor
Copy link
Member

Interestingly, the line where the error is being reported is the call to srv.Close in a testing cleanup function registered by TestScript.

	t.Cleanup(func() {
		if err := srv.Close(); err != nil {
			t.Fatal(err)
		}
	})

Looking at the (*vcstest.Server).Close method, it's likely that the error is coming from a call to os.RemoveAll.

@FiloSottile
Copy link
Contributor Author

FiloSottile commented Jan 3, 2025

The pattern in #66337 is definitely broad, and it hasn't progressed beyond the NeedsInvestigation / no status state yet. If it's narrowed down to something that doesn't match these errors, then it creates room for this failure mode to be tracked in another issue.

Ok, I think I made this issue the watchflakes tracking issue for this error message.

Edit: actually, if lowest-numbered wins, I think the old catchall will win.

@dmitshur dmitshur moved this to Active in Test Flakes Jan 3, 2025
@matloob
Copy link
Contributor

matloob commented Jan 3, 2025

So I'm not super familiar with this code, but I think the problem is in the vcweb handler in cmd/go/internal/vcweb/auth.go. I think we should be closing the accessFile, but we don't seem to be doing that. Leaving the file open when we try to delete it would cause this issue on Windows.

@ianlancetaylor
Copy link
Member

ianlancetaylor commented Jan 3, 2025

@matloob Thanks for the pointer. That code is clearly incorrect, and I'll send a CL, but I don't understand why the problem would have just started appearing a few weeks ago.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/640175 mentions this issue: cmd/go/internal/vcweb: close the .access file

@gopherbot
Copy link
Contributor

Found new dashboard test flakes for:

#!watchflakes
default <- pkg == "cmd/go" && test == "TestScript" && `The process cannot access the file because it is being used by another process.`
2024-12-12 17:06 go1.24-windows-386 release-branch.go1.24@817d7bdc cmd/go.TestScript [ABORT] (log)
=== RUN   TestScript
vcs-test.golang.org rerouted to http://127.0.0.1:49842
https://vcs-test.golang.org rerouted to https://127.0.0.1:49843
go test proxy running at GOPROXY=http://127.0.0.1:49844/mod
    script_test.go:54: remove C:\b\s\w\ir\x\t\cmd-go-test-3795577681\vcstest3943647372\auth\or401\.access: The process cannot access the file because it is being used by another process.
2024-12-12 20:58 gotip-windows-amd64 go@14e5093e cmd/go.TestScript [ABORT] (log)
=== RUN   TestScript
vcs-test.golang.org rerouted to http://127.0.0.1:49834
https://vcs-test.golang.org rerouted to https://127.0.0.1:49835
go test proxy running at GOPROXY=http://127.0.0.1:49836/mod
    script_test.go:54: remove C:\b\s\w\ir\x\t\cmd-go-test-1581749979\vcstest1397970513\auth\or401\.access: The process cannot access the file because it is being used by another process.
2024-12-26 20:33 gotip-windows-386 go@cce75da3 cmd/go.TestScript [ABORT] (log)
=== RUN   TestScript
vcs-test.golang.org rerouted to http://127.0.0.1:49881
https://vcs-test.golang.org rerouted to https://127.0.0.1:49882
go test proxy running at GOPROXY=http://127.0.0.1:49883/mod
    script_test.go:54: remove C:\b\s\w\ir\x\t\cmd-go-test-2796287422\vcstest2369482085\auth\or401\.access: The process cannot access the file because it is being used by another process.
2024-12-30 17:19 gotip-windows-386 go@fd5e0d26 cmd/go.TestScript [ABORT] (log)
=== RUN   TestScript
vcs-test.golang.org rerouted to http://127.0.0.1:53883
https://vcs-test.golang.org rerouted to https://127.0.0.1:53884
go test proxy running at GOPROXY=http://127.0.0.1:53885/mod
    script_test.go:54: remove C:\b\s\w\ir\x\t\cmd-go-test-2286365711\vcstest4207156862\auth\or401\.access: The process cannot access the file because it is being used by another process.

watchflakes

gopherbot pushed a commit that referenced this issue Jan 3, 2025
For #71112

Change-Id: Ifda4fc8de148c42a2154da54b53d7215b9a6faa0
Reviewed-on: https://go-review.googlesource.com/c/go/+/640175
LUCI-TryBot-Result: Go LUCI <[email protected]>
Auto-Submit: Ian Lance Taylor <[email protected]>
Auto-Submit: Ian Lance Taylor <[email protected]>
Reviewed-by: Michael Matloob <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
@ianlancetaylor
Copy link
Member

CL 640175 is submitted. Let's see if the problem keeps happening.

@gabyhelp gabyhelp added the Bug Issues describing a bug in the Go implementation. label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues describing a bug in the Go implementation. GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows
Projects
Status: Active
Development

No branches or pull requests

6 participants