fix: gracefully handle race condition between parallel builds #10
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.
I am receiving build failures when I run 2 parallel builds that both run setup-mint when they startup. You can reproduce this scenario by creating 2 workflows that get triggered when a PR is opened and both workflows run setup-mint action. 1 will succeed with saving the cache, the other will fail early and give error message "Unable to reserve cache with key -macOS-X64-irgaly/setup-mint-master, another job may be creating this cache."
I believe this is a race condition between the parallel builds where they both attempt to reserve the github actions cache using the same cache key. One way to handle this scenario is to not fail the action when this race condition occurs, since you only need 1 of the parallel builds to save the cache. The other build can skip saving and move on.
References:
oven-sh/setup-bun#45 - experiencing the same issue as this person actions/cache#485 (comment) - explaining the idea of how caches are reserved