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

Pops::Loaders thread safety: synchronization in find_loader and [] #9299

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jstange
Copy link

@jstange jstange commented Mar 19, 2024

Re: #9252

This patch makes reads and writes to Puppet::Pops::Loaders' instance variable @module_resolver thread-safe.

Without this, enabling threading on our stock Puppet 7 masters yields errors of the following form, on ~3-5% of agent runs:

ERROR [qtp735649759-289] [puppetserver] Puppet Server Error: Evaluation Error: Error while evaluating a Type-Name, Internal Error: Attempt to redefine loader named '<foo> private' (file: /path/to/our/modules/foo/manifests/init.pp, line: 12, column: 18) on node clientnode.example.com

(I theorize that this a race condition between multiple modules in our ecosystem resolving dependencies-in-common at the same time)

Applying this patch does seem to correct the behavior. We've been running this for a while on two of our active masters with no ill effects.

It seems likely that there are other thread-shared instance variables that should be wrapped in environment.lock.synchronize. I'm not particularly familiar with this code, so I stuck with the method that was trigger errors for us, as well as a nearby sibling, where it was clear that there was no danger of introducing deadlocks.

@jstange jstange requested a review from a team as a code owner March 19, 2024 14:15
@puppetlabs-jenkins
Copy link
Collaborator

Can one of the admins verify this patch?

@CLAassistant
Copy link

CLAassistant commented Mar 19, 2024

CLA assistant check
All committers have signed the CLA.

@joshcooper joshcooper added the bug Something isn't working label Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants