-
Notifications
You must be signed in to change notification settings - Fork 651
#2578: Retry some file reads and writes to avoid 'file in use' on gitversion.json #2581
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
Conversation
@MarkusHorstmann we already have a class for retry mechanism, do you mind checking this one
|
Absolutely. Missed that helper. 2 questions (not familiar with the codebase so asking for guidance before I start):
|
Took a stab at the above. Hope this is not too impactful. |
src/GitVersion.Core/VersionConverters/OutputGenerator/OutputGenerator.cs
Outdated
Show resolved
Hide resolved
Please rebase on top of |
@@ -53,10 +54,20 @@ public void Dispose() | |||
|
|||
public ICommit FindMergeBase(ICommit commit, ICommit otherCommit) | |||
{ | |||
var mergeBase = repositoryInstance.ObjectDatabase.FindMergeBase((Commit)commit, (Commit)otherCommit); | |||
return new Commit(mergeBase); | |||
return new OperationWithExponentialBackoff<LockedFileException, ICommit>(new ThreadSleep(), log, () => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, do you think we can move the retry from the GitRepository
and from the LibGit2Sharp implementation upper the stack to the consumer. That will make it more consistent.
…ion_PreReleaseLabelWithDash" This reverts commit f2b6131.
@MarkusHorstmann thank you so much for your contributions 👍 |
Should this PR have closed #2410 or do we intend to introduce the file lock? |
Description
Retry some file reads and writes to avoid 'file in use' on gitversion.json. Up to 6 attempts will be made on any IO exception, with exponential back-off between retries. The contentious operations typically write and read the entire gitversion.json file and tend to be sub-second on typical systems.
Also retry LibGit2Sharp.LockedFileException failures on some GIT operations.
Related Issue
Closes #2578.
Mitigates #1031.
Motivation and Context
With multi-targeted projects and solutions with many projects, there is read/write contention on the gitversion.json files, resulting in intermittent failures. See linked issue for one repro.
How Has This Been Tested?
Used in local builds on our repos. Reproduced failures like this, and confirmed the fix eliminates them. https://github.com/TRUMPF-IoT/cdePlugins/pull/23/checks?check_run_id=1827871101.
Checklist: