-
Notifications
You must be signed in to change notification settings - Fork 25
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: fixes EOF error when having HTTP POST requests #342
fix: fixes EOF error when having HTTP POST requests #342
Conversation
mittens requests are recycled within the requests channel. Once the body i/o reader was closed, succeeding requests were not succesful.
const respType = "http" | ||
|
||
var body io.Reader |
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.
Re-introducing the i/o reader per request
if err != nil { | ||
log.Printf("Failed to create request: %s %s: %v", method, url, err) | ||
return response.Response{Duration: time.Duration(0), Err: err, Type: respType} | ||
} | ||
|
||
if req.Body != nil { |
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.
Body must be closed when there is no error and when a body is present. In case of GET there is no Body.
}, nil | ||
} | ||
|
||
func compressGzip(data []byte) io.Reader { | ||
pr, pw := io.Pipe() |
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.
Optimization not required as mittens requests are re-used in the channel. So compression is only done once for each request element.
@@ -188,6 +191,36 @@ func TestGrpcAndHttp(t *testing.T) { | |||
assert.True(t, readyFileExists) | |||
} | |||
|
|||
func TestCompressWithGZip(t *testing.T) { |
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.
e2e test for compression support
@nikos912000 Sorry for having to fix this directly after the release of v1.46. Unfortunately all existing tests were not able to detect an issue within the request processing. I tried to add a useful test here, but maybe there should be another one. |
@nikos912000 @worldtiki Review required |
pw.CloseWithError(err) | ||
}() | ||
return pr | ||
func compressGzip(data []byte) (io.Reader, error) { |
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.
Aligned implementation of all compression functions
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.
Thanks for this.
Something looks wrong with the flags in the tests, these are no more passed - I don't think it was this PR that caused it.
A bit busy to debug properly atm but I will try find some time and let our teams know.
I debugged this and recalled that we identified this issue in the past. It has to do with the fact that the command line arguments are parsed after setting their default values. For instance, the As this does not have to do with this PR, happy to merge it. |
I tested it now in our pre-production and afterwards production. Works like a charm. HTTP/2 and stream compression. |
@jrauschenbusch thank you for contribution. this is now released in https://github.com/ExpediaGroup/mittens/releases/tag/1.47.0 |
Mittens requests are recycled within the requests channel. Once the body i/o reader was closed, succeeding requests were not successful.
📝 Description
Currently mittens is broken due to an bug introduced in v1.46. During the processing of requests an i/o reader is passed to the client which leads to EOF errors on server side when the same request body is read the 2nd time. Hence only the first request of a warm-up succeeds and all others fail. This should only affect configurations using POST data, but this needs to be fixed.
🔗 Related Issues