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

martian: cancel request context on downstream disconnection #1004

Closed
wants to merge 5 commits into from

Conversation

Choraden
Copy link
Contributor

This patch introduces a background read mechanism for martian proxy conn. Background read affects simple roundTrip path. Once the request body is consumed in roundTrip, background read will begin, canceling conn context in an error occurs. This idea was inspired by http.Server.

This partially fixes #800. The other patch in progress.

This improves performance by limiting the number of backgroundRead goroutines to 1.
The read access is controlled by a read semaphore.
Notice that it used to return neterr.Timeout error as closable.
This was wrong as we want to retry on any timeout error.
This is why handle loop checks for maxConsecutiveErrors.
@Choraden Choraden requested a review from mmatczuk January 27, 2025 11:34
@Choraden
Copy link
Contributor Author

The requirement of using bufio.Reader in http.ReadRequest makes this problem much harder. To implement it properly, we would need to drift away from http package. I'll follow up with other solutions.

@Choraden Choraden closed this Jan 28, 2025
@Choraden Choraden deleted the hg/cancel_ctx_on_conn_close branch January 28, 2025 14:11
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.

martian: cancel request context when connection is closed
1 participant