Skip to content
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

feat(cache): add a mutex utility and prevent parallel processing with the same cache key #30815

Merged

Conversation

secustor
Copy link
Collaborator

Changes

  • Adds a mutex implementation based on our cache key system.
  • This PR also adds the lock usage to the cache decorator

Context

This prevents race conditions where we have cache miss and then multiple stacks are getting the same packages.
Where this can have a big impact are where we are limited on API calls or lookups are expensive until cached.
e.g. Terraform artifact updates, lookups for the deb datasource.

It could be interesting for the bigger installations to extend this to Redis later on so this is also the case if multiple instances share the same cache.

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@secustor secustor requested a review from viceice August 16, 2024 06:27
Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise LGTM

lib/util/mutex.ts Outdated Show resolved Hide resolved
Co-authored-by: Michael Kriese <[email protected]>
@viceice viceice added this pull request to the merge queue Aug 16, 2024
Merged via the queue into renovatebot:main with commit f042ae4 Aug 16, 2024
38 checks passed
@secustor secustor deleted the feat/do-not-run-cache-misses-in-parralell branch August 16, 2024 17:37
@renovate-release
Copy link
Collaborator

🎉 This issue has been resolved in version 38.39.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants