-
Notifications
You must be signed in to change notification settings - Fork 18k
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/internal/lockedfile: clean *.lock files #30409
Comments
The version-specific locks are used in two places: go/src/cmd/go/internal/modfetch/fetch.go Line 76 in 42e8b9c
go/src/cmd/go/internal/modfetch/fetch.go Line 158 in 42e8b9c
Since those guard the creation of |
Deleting lockfiles is subtle, and it would be very easy to introduce races that way. On POSIX systems we use advisory locks, which do not prevent the file from being changed or deleted by another process while locked. Consider the following sequence:
Now processes B and C are both updating the To fix that situation, we would need to always delete the file before unlocking it, and always check the identity of a file after locking it.
That requires a much more intricate locking sequence (B needs to verify the identity of the file it locked), and I'm not entirely sure that it's portable (I don't know whether Windows allows locked files to be removed or renamed). |
See previously #29434. |
What version of Go are you using (
go version
)?It is necessary to clean these *.lock files in
$GOPATH/pkg/mod/cache/download/server.com/xxx/repo
?And these files's size always 0. Maybe we can remove these files after unlock.
From code comment:
cc @bcmills
The text was updated successfully, but these errors were encountered: