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

fix: rpcenc: Don't hang when source dies #10116

Merged
merged 1 commit into from
Jan 31, 2023
Merged

fix: rpcenc: Don't hang when source dies #10116

merged 1 commit into from
Jan 31, 2023

Conversation

magik6k
Copy link
Contributor

@magik6k magik6k commented Jan 25, 2023

Related Issues

Couldn't find anything about "AddPiece stuck" where it wasn't showing up in either sealig sched-diag or sealing jobs, but maybe there is an issue about that

Fixes #10115

Proposed Changes

Additional Info

Checklist

Before you mark the PR ready for review, please make sure that:

  • Commits have a clear commit message.
  • PR title is in the form of of <PR type>: <area>: <change being made>
    • example: fix: mempool: Introduce a cache for valid signatures
    • PR type: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, test
    • area, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps
  • New features have usage guidelines and / or documentation updates in
  • Tests exist for new functionality or change in behavior
  • CI is green

@magik6k magik6k requested a review from a team as a code owner January 25, 2023 15:54
Copy link
Contributor

@travisperson travisperson left a comment

Choose a reason for hiding this comment

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

I kind of understand what this test is doing, and I think it looks good, but probably worth having another set of eyes on it.

return
}
}
}()
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this extra closed channel do when we are immediately closing it? Isn't this going to race between the two select cases and possibly immediately returning without reading anything off of wr.res?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It cleans up this goroutine.

wr.res can only be written in wr.beginOnce, and is only written to once, so by calling it below, we know that wr.res must have been written to already.

This bit of code spins up a go-routine which will read pending sends into wr.res, then will make sure that wr.beginOnce was done (so wr.res can't be written to anymore), then it will shutdown the draining goroutine by closing the closed channel.

lib/rpcenc/reader_test.go Show resolved Hide resolved
Copy link
Contributor

@arajasek arajasek left a comment

Choose a reason for hiding this comment

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

LGTM

@magik6k magik6k merged commit beb70a3 into master Jan 31, 2023
@magik6k magik6k deleted the fix/rpcenc-hang branch January 31, 2023 08:18
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.

rpcenc: Reader redirection may get stuck if the reader request is cancelled
3 participants