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

Improve config sync locking (support/2.12) #8511

Merged
merged 5 commits into from
Nov 27, 2020

Conversation

julianbrost
Copy link
Contributor

This pull request greatly simplifies the locking during an incoming config sync and removes a spin lock that got introduced as a workaround.

History

#7230 recognized the need that the incoming config sync must not happen concurrently and added a mutex. #7936 then fixed a shortcoming that the mutex was not hold during the complete sync and reload process by using a icinga::Shared<boost::mutex::scoped_lock> which is passed to a callback function by capturing it in a lambda and therefore the unlock operations runs when the callback is destroyed. Unfortunately, both std::mutex and boost::mutex have undefined behavior when the unlock operation happens in a different thread than the lock operation, which is a problem as the callback can run on any other worker thread. As a workaround, #8364 introduced a spin lock, that does not have undefined behavior in this case.

Changes

With this pull request, the config sync and subsequent reload no longer post a callback to a worker thread but instead just waits for the process to finish while simply holding the lock without any shared pointer magic. To do so, a new method WaitForResult() is added to icinga::Process which allows to block until the process has finished.

fixes #8336
fixes #8507
backport of #8488

This avoid having to pass a lock implictly using the captured variables
of a lambda.
Merge AsyncTryActivateZonesStage and TryActivateZonesStageCallback and
name the result TryActivateZonesStage. The old split was a leftover from
the one being a callback function with no actual meaningful separation.
No longer needed as its only user now uses std::mutex.
@icinga-probot icinga-probot bot added this to the 2.12.3 milestone Nov 27, 2020
@icinga-probot icinga-probot bot added area/distributed Distributed monitoring (master, satellites, clients) area/windows Windows agent and plugins bug Something isn't working enhancement New feature or request ref/NC labels Nov 27, 2020
@Al2Klimov Al2Klimov merged commit f3f3a94 into support/2.12 Nov 27, 2020
@icinga-probot icinga-probot bot deleted the feature/improve-config-sync-locking-2.12 branch November 27, 2020 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/distributed Distributed monitoring (master, satellites, clients) area/windows Windows agent and plugins bug Something isn't working enhancement New feature or request ref/NC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants