Repository navigation
fix(ci): a sync clears git lock files left by an interrupted git - #82
Merged
Merged
Conversation
A build cancelled or a daemon stopped mid-checkout leaves .git/index.lock in the checkout, and every later sync of that repo failed with 'Unable to create index.lock: File exists' until someone removed the file by hand. Each sync now removes any git lock it finds in the checkout before it starts (the repo's git dir, its refs, and each submodule's git dir) and names each one in the build log. The sync holds the workspace lock, so a lock still on disk has no owner.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Ben · project thread
Problem
A build that is cancelled, or a daemon that stops, while git is checking out leaves
.git/index.lockin the work-root checkout. Every later sync of that repo then fails within seconds:It stayed that way until someone removed the file by hand.
Change
syncReponow removes any git lock file it finds in an existing checkout before it runs git:*.lockin the repo's git dir, under itsrefs, and the same in each submodule's git dir under.git/modules. Each removal is named in the build log.This is safe because a sync runs under the workspace lock, so a git lock still on disk has no live owner among cooperating writers.
docs/ci.mdsays so, and says not to run git by hand in a work-root checkout without taking that lock.Tests
TestWorkspaceSyncClearsLocksLeftByAnInterruptedGit: plants four locks (index, HEAD, a ref, a submodule index), checks as a control that plain git refuses to check out over them, then checks the sync succeeds, lands on the pinned commit, removes all four and logs each.go test ./...passes.