-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[FIXED] Locking issue around account lookup/updates #1131
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
Ensure that lookupAccount does not hold server lock during updateAccount and fetchAccount. Updating the account cannot have the server lock because it is possible that during updateAccountClaims(), clients are being removed, which would try to get the server lock (deep down in closeConnection/s.removeClient). Added a test that would have show the deadlock prior to changes in this PR. Signed-off-by: Ivan Kozlovic <[email protected]>
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.
Looks pretty good.
// This error could mask expired, so just return expired here. | ||
return nil, ErrAccountExpired | ||
} | ||
} else { |
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.
@derekcollison Also want to bring your attention to this change. The original code, as you can see, would return the account (even if expired) if there was no account resolver defined. This is because err
is initialized to nil
.
With this change, I return ErrAccountExpired
if the account is expired and there is no resolver. Is that correct?
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 believe so.
Make it a function that grabs server lock/unlock and invokes registerAccountNoLock(). Use that function when already under the server's lock. Signed-off-by: Ivan Kozlovic <[email protected]>
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.
LGTM
Ensure that lookupAccount does not hold server lock during
updateAccount and fetchAccount.
Updating the account cannot have the server lock because it is
possible that during updateAccountClaims(), clients are being
removed, which would try to get the server lock (deep down in
closeConnection/s.removeClient).
Added a test that would have show the deadlock prior to changes
in this PR.
Signed-off-by: Ivan Kozlovic [email protected]