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
transport: unblock read throttling when controlbuf exits #4447
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Also add this?
This won't race with any other goroutine, because the caller (the
loopyWriter()
goroutine) is the only goroutine that ever sets the channelThere 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.
Races are actually avoided by taking the lock and setting
c.err
, andget
, which sets the channel, checking the error. This is becausefinish
may also be called byt.Close
whileget
is in flight.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.
Oh,
t.Close()
also callsfinish()
? Why would it need to?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 don't think it needs to now. I can remove it, but I don't think it simplifies things, really.
Actually, I think we could change things a little bit to improve them slightly.
finish
from adefer
inrun
.trfChan
to achan struct{}
instead ofatomic.Value
and access it withatomic.___Pointer
finish
could closetrfChan
directly without even the atomic load, since we knowfinish
is only called byrun
.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.
And the "race" I'm talking about here is not read/write race.
It's that if
finish()
unblocks this channel, but another goroutine sets it to block again, before thereader()
has a chance to unblock, leading to another deadlock.(and it's also handled by the error check)
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.
There is no read/write race due to the use of the atomic. I think we were talking about the same thing. And if
finish
is called byClose
, it can happen whileget
is in flight, which, ifget
didn't checkc.err
, could encounter this race. Anyway, let me know what you want me to do here.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.
The change in this PR is OK.
We should cleanup the transport code later (when? 🤷♂️).
controlbuf
) is closed by the reader (loopyWriter()
) instead of the writer (reader()
) (hahahahaha)t.Close()
is probably part of the cause that RPCs tend to fail withtransport is closing
reader()
, and the other places just tellsreader()
to close, it might make things cleanerThere 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.
#4459