-
Notifications
You must be signed in to change notification settings - Fork 851
Optimize: Keep cont->mutex locked, during probe the bucket by hash object within HostDBProcessor::getby #4916
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
Conversation
iocore/hostdb/HostDB.cc
Outdated
| loop = false; // Only loop on explicit set for retry. | ||
| // find the partition lock | ||
| // | ||
| // TODO: Could we reuse the "mutex" above safely? I think so but not sure. |
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.
Should delete this comment, it's clearly not safe because the lock on line 619 is scoped and has been dropped at this point.
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.
deleted.
iocore/hostdb/HostDB.cc
Outdated
| if (!aforce_dns) { | ||
| MUTEX_TRY_LOCK(lock, cont->mutex, thread); | ||
| if (!lock.is_locked()) { | ||
| goto Ldelay; |
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.
I'm very much not fond of goto. In this case, I'd be tempted to change the do;while(loop) into a while (loop). E.g. something like
MUTEX_TRY_LOCK(...);
bool loop = lock.is_locked();
while (loop) {
loop = false; // ...
// ...
}
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.
Updated per your suggestion.
613d359 to
784caa6
Compare
SolidWallOfCode
left a comment
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.
Thanks.
|
Could it be dead lock ? See trafficserver/iocore/hostdb/HostDB.cc Lines 668 to 683 in 784caa6
I'm not sure here, But the HostDBContinuation use the same bucket lock. And it grab the bucket lock first then get continuation's lock (which equals to action.mutex). I know that the the cont will run after |
|
I think not. The locking is try, not hard locks, which prevents deadlock. Any continuation that gets one lock but not the other will drop the acquired lock rather than waiting on the second lock. |
scw00
left a comment
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.
Thanks +1 ..
…ject within HostDBProcessor::getby
|
Rebased to resolve merge conflicts with #4926. |
No description provided.