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

rpcserver: fix recoveryPending attribute #355

Merged
merged 1 commit into from
Apr 12, 2022
Merged

Conversation

positiveblue
Copy link
Contributor

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.

@positiveblue positiveblue changed the title rpcserver: fix recoveryPending atrib. rpcserver: fix recoveryPending attribute Apr 11, 2022
Copy link
Member

@guggero guggero left a 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.
Copy link
Member

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).

Copy link
Member

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.

Copy link
Member

@bhandras bhandras left a 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()
Copy link
Member

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.

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.
@positiveblue positiveblue merged commit 6d93ea0 into master Apr 12, 2022
@guggero guggero deleted the account-recover-fix branch May 5, 2022 15:25
positiveblue pushed a commit to positiveblue/pool that referenced this pull request Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants