-
Notifications
You must be signed in to change notification settings - Fork 30
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
Make Digest subclass lookup thread-safe in lru_cache #109
Conversation
r10k content_synchronizer uses Forge v3 API when installing a module: https://github.com/puppetlabs/r10k/blob/4.0.0/lib/r10k/module/forge.rb#L95 https://github.com/puppetlabs/r10k/blob/4.0.0/lib/r10k/module/forge.rb#L128 https://github.com/puppetlabs/r10k/blob/4.0.0/lib/r10k/module/forge.rb#L176 r10k uses a thread pool to install the modules, therefore the Forge v3 API calls have to be thread safe, and so does the LruCache class used to cache API responses. If LruCache is left not thread safe, the same error as reported in r10k issue #979 happens. puppetlabs/r10k#979
@cmd-ntrf thanks for the PR. Any chance you can add a test for this? |
It appears some tests have been written but commented: @hsnodgrass is probably more qualified than I am to add test. |
I'm not really sure how to unit test thread-safety in a deterministic manner. It looks like we could use https://github.com/yegor256/threads, but I have no experience with it. |
I did find this merged PR for Puma which makes the same change: puma/puma#2744. Personally, I think we're ok to merge this change without a specific test. This is a known issue in Ruby that I wasn't aware of when I wrote the cache |
Is this why I've just hit the following in r10k? (4.0.0 running in an AWS lambda function...)
|
yes. You can mitigate the problem by freezing |
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.
LGTM
r10k content_synchronizer uses Forge v3 API when installing a module: https://github.com/puppetlabs/r10k/blob/4.0.0/lib/r10k/module/forge.rb#L95 https://github.com/puppetlabs/r10k/blob/4.0.0/lib/r10k/module/forge.rb#L128 https://github.com/puppetlabs/r10k/blob/4.0.0/lib/r10k/module/forge.rb#L176
r10k uses a thread pool to install the modules, therefore the Forge v3 API calls have to be thread safe, and so does the LruCache class used to cache API responses.
If LruCache is left not thread safe, the same error as reported in r10k issue #979 happens.
puppetlabs/r10k#979