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
stored: fix authentication race condition / deadlock #1732
Merged
BareosBot
merged 13 commits into
bareos:master
from
sebsura:dev/ssura/master/fix-authentication
Mar 18, 2024
Merged
stored: fix authentication race condition / deadlock #1732
BareosBot
merged 13 commits into
bareos:master
from
sebsura:dev/ssura/master/fix-authentication
Mar 18, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sebsura
force-pushed
the
dev/ssura/master/fix-authentication
branch
from
March 12, 2024 12:42
fc22222
to
074ad77
Compare
pstorz
requested changes
Mar 14, 2024
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.
Please see comments
6 tasks
sebsura
force-pushed
the
dev/ssura/master/fix-authentication
branch
from
March 14, 2024 13:53
074ad77
to
4a50667
Compare
This was referenced Mar 14, 2024
pstorz
approved these changes
Mar 18, 2024
The condition variable is not used correctly: // reader 1| while (!unprotected) { 2| wait(cond_var) } // writer 3| unprotected = true; 4| signal(cond_var) The execution order 1->3->4->2 will cause a deadlock. This is why the wait command takes a mutex: Everything that might change the condition to be true needs to lock the mutex, this way we can ensure that we either see the updated value or the wait sees the signal. Since jcr->authenticate is used all over the place in a lot of different situations, this problem could not be easily fixed by just protecting that variable (we do not want weird deadlocks to happen after all). We just do not rely on jcr->authenticate anymore when it comes to waiting on job start. Instead we have a single, properly protected bool `client_available` that we can wait on. This bool obviously needs to be set by whoever authenticates the FD/SD connection, otherwise the job will deadlock. But at least that is easily fixable.
once that timeout is reached, we kill the daemons and create a trace.
BareosBot
force-pushed
the
dev/ssura/master/fix-authentication
branch
from
March 18, 2024 13:54
603b237
to
f229099
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thank you for contributing to the Bareos Project!
Sometimes the fd and sd do not agree on the authentication status of the connection, which leads to both of them waiting for the other.
This is in part caused by not using condition variables correctly, which causes the sd to not notice that the
authenticated
condition changed from false to true.This PR also adds an additional timeout check to our systemtests. If a single run_bconsole invocation takes more than 100 seconds, then the testrunner will create backtraces of the currently running daemons and exit the test with exit code 124.
This should make it easier to debug hangs (like the one above) in our ci pipeline.
Please check
If you have any questions or problems, please give a comment in the PR.
Helpful documentation and best practices
Checklist for the reviewer of the PR (will be processed by the Bareos team)
Make sure you check/merge the PR using
devtools/pr-tool
to have some simple automated checks run and a proper changelog record added.General
Source code quality
Tests