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

Order mixclient and syncer shutdown #2463

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

jrick
Copy link
Member

@jrick jrick commented Jan 23, 2025

During clean shutdown, signal the mixing client to shutdown first, waiting for it to finish running, before closing the RPC and SPV syncers.

Updates the mixing module to a version that supports continuing active mixes before terminating the mixing client.

During clean shutdown, signal the mixing client to shutdown first, waiting for
it to finish running, before closing the RPC and SPV syncers.

Updates the mixing module to a version that supports continuing active mixes
before terminating the mixing client.
spv/sync.go Show resolved Hide resolved
@jrick
Copy link
Member Author

jrick commented Jan 24, 2025

there's another bug i'm seeing in the spv code now. if any of the other errgroup handlers (which take the gctx) error, they will all stop properly, except for the one running the mixing client because its context has not been canceled yet. I think some additional context wrapping is unavoidable here.


// If gctx has not yet been canceled, do so here now.
// walletCtx is canceled after either ctx or gctx is canceled.
<-walletCtx.Done()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right to me yet.

In the case an error is returned from Run unrelated to the context being canceled, that error would be returned which would cause the group context to be canceled so everything would be fine.

However, when wallet.Run returns nil, walletCtx will never be canceled afaict. Thus, it would just hang here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be cancelled by the goroutine started above this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is assuming there is an error in the goroutines in the group though. There won't necessarily be one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but they all return errors....

have you ran this and seen it hang?

Copy link
Member

@davecgh davecgh Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen any issues, but I'm just considering the edge cases. So long as there is a never a case where the grouped goroutines all exit without an error, then the code is fine.

My worry is just basically what I described. Namely, wallet.Run returns nil and then it just sits and waits, effectively until either there is an error in the group or the outer context is canceled. That part is correct.

However, it implies all of the goroutines in the group will be sitting there doing nothing after wallet.Run returns until eventually the outer context is canceled even though they really should be exiting after wallet.Run returns unconditionally so that syncer.Run returns without error versus sitting around in a defunct state (aka wallet.Run is no longer running, but all of the goroutines in the group are).

EDIT: So long as you're fine with that outcome, I'll approve it.

Copy link
Member

@davecgh davecgh Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, after looking through more of the surrounding code, I guess it's just the poor naming of things that misled me and those other goroutines are supposed to remain active until the outer context is canceled regardless of whether or not the "wallet" is running. It'll still be processing p2p messages, fetching filters, etc.

I was completely misled by the naming to believe it was running the entire wallet (as it's named) as opposed to some optional additional background tasks.

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.

2 participants