ensure responseChannel is drained#660
Merged
Merged
Conversation
Signed-off-by: Teo Koon Peng <koonpeng@google.com>
ensonic
reviewed
Apr 16, 2026
| if err != nil { | ||
| slog.Error("Closing backend connection", | ||
| slog.String("ID", *resp.Id), ilog.Err(err)) | ||
| // This is also closed in streamToBackend. In most cases this is safe but it depends on the transport. |
Contributor
There was a problem hiding this comment.
Can you add more detail for which transport this Close() call would be needed?
Contributor
Author
There was a problem hiding this comment.
The "default" http client doesn't panic. I didn't really tested if it would panic in our case.
In theory, we can also not close here. The server should eventually close the connection, then streamBackend will end up closing hresp.Body. Closing it here would just propagate the disconnect to the backend faster.
Contributor
There was a problem hiding this comment.
Thanks maybe reword as:
// This is also closed in streamToBackend. Closing here too to ensure the disconnect propagates faster in case e.g. the default http client is used.
Signed-off-by: Teo Koon Peng <koonpeng@google.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 is a potential for deadlocks
core/src/go/cmd/http-relay-client/client/client.go
Lines 708 to 712 in f173d97
if we exit the loop preemptively, we fail to fully consume
responseChannelandcore/src/go/cmd/http-relay-client/client/client.go
Line 487 in f173d97
might deadlock.
#222 fixes the error handling which may have caused the deadlock. Before, it checks for incorrect
backoff.PermanentErrorwhich never happens so theresponseChannelis always fully consumed.