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

Fix races occuring when two threads expand variables at the same time #737

Merged
merged 2 commits into from
Feb 2, 2025

Conversation

zacikpa
Copy link
Contributor

@zacikpa zacikpa commented Jan 23, 2025

While fixing this, I got confused by the naming of the PluginLoader class. In the first commit, I propose to rename it to ClassLoader, and fix one of its methods so that it truly behaves like an abstract class.

For the race fix itself, see the second commit.

Resolves: RHEL-75773

The `PluginLoader` class is used as an interace implemented by
all kinds of repositories: of profile plugins, functions, monitors.
While these are all technically "plug-in", the naming is confusing.

The commit also updates the `load_all_plugins` method of the class
(now `load_all_classes`) to use the class loader parameters
(prefix, namespace) instead of hardcoded ones.
Previously, the parser state would be shared, creating races
when two threads would attempt to expand functions in strings
at the same time (e.g., when a device was hotplugged during
TuneD initialization).

The change requires minor refactoring: the function `Repository`
class is now the one providing the expansion API to the `Variables`
class instead of the original `Functions` class (now renamed to
`Parser` and newly created for each expansion).

Resolves: RHEL-75773
@jmencak
Copy link
Contributor

jmencak commented Jan 23, 2025

Thank you for the PR, Pavol, much appreciated! The basic tests with NTO on OCP with this change pass. I'm currently running a test that's trying to reproduce the original issue. I had success reproducing the issue with the old code without this fix.

So far, I wasn't able to reproduce the issue with the new code. I want to test this fix at least over night. I'll report tomorrow morning how it went.

@jmencak
Copy link
Contributor

jmencak commented Jan 24, 2025

No race found with overnight testing. @yarda , it would be great to have this in FDP 25.A.

@zacikpa
Copy link
Contributor Author

zacikpa commented Jan 24, 2025

Thanks for the thorough testing, @jmencak!

Copy link
Contributor

@yarda yarda left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.

@yarda yarda merged commit 374697b into redhat-performance:master Feb 2, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants