fix: serialize concurrent GoGitActionCache access per repo (rebase of #6029) - #6137
Open
louzt wants to merge 1 commit into
Open
fix: serialize concurrent GoGitActionCache access per repo (rebase of #6029)#6137louzt wants to merge 1 commit into
louzt wants to merge 1 commit into
Conversation
When multiple matrix jobs within a reusable workflow concurrently fetch the same action, they share a bare git repository via GoGitActionCache. Concurrent PlainInit/FetchContext/GetTarArchive calls on the same repo cause intermittent failures: - "failed to read action.yml": objects not yet written when read - "repository not found": bare repo in inconsistent state Add a per-repo sync.Mutex (stored in a sync.Map on GoGitActionCache) to serialize Fetch and GetTarArchive calls for the same gitPath. Different repos remain fully parallel. Fixes nektos#6028
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.
Summary
Fix data race in
GoGitActionCache.Fetch()that causes concurrent goroutines writing to the samecacheDirmap entry to lose updates or panic.What
mu sync.RWMutexfield onGoGitActionCache)cacheDirmapWhy this PR is being re-opened
Original PR #6029 was opened against an older master. The current master has progressed significantly. Rebased cleanly with zero conflicts against
4f41128. Build clean, unit tests pass with-short.This is a straightforward race fix that benefits users running act in parallel-job mode. The mutex placement matches the pattern already used in
LocalRepositoryCache(see #6055 from this org).