-
Notifications
You must be signed in to change notification settings - Fork 47
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
rpcserver: fix recoveryPending
attribute
#355
Conversation
recoveryPending
atrib.recoveryPending
attribute
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.
Nice fix, thank you!
s.recoveryPending = true | ||
// Mark the recovery process as done whenever we finish. |
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 we move this whole block just one line down, so it's after the Unlock()
? That way it's a bit easier to reason about whether this could lead to a deadlock or not (in case you miss the defer
when scanning the code linearly).
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.
Sorry, my comment was a bit inaccurate. But the s.recoveryPending = true
should still be within the lock.
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 👍
@@ -1148,10 +1148,17 @@ func (s *rpcServer) RecoverAccounts(ctx context.Context, | |||
|
|||
s.recoveryMutex.Lock() | |||
if s.recoveryPending { | |||
defer s.recoveryMutex.Unlock() | |||
s.recoveryMutex.Unlock() |
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.
nit: alternatively we could just use an atomic int to avoid the (slightly complex) locking logic.
72386eb
to
973e7d0
Compare
The rpcserver cannot have more than one account recovery process running at once. The server uses a internal attribute (`recoveryPending`) that is set to true when a new recovery process starts. However, that attribute was only set to false if the process ended successfully, leaving the server unable to try more recoveries after a failure.
973e7d0
to
777dce5
Compare
Admin RPC Financial Report endpoint
The rpcserver cannot have more than one account recovery process running
at once. The server uses a internal attribute (
recoveryPending
) thatis set to true when a new recovery process starts. However, that
attribute was only set to false if the process ended successfully,
leaving the server unable to try more recoveries after a failure.