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
Allow XRootD to return trailers indicating failure #1912
Conversation
HTTP provides a response to include a "trailer" in addition to the better-known "header". If a user sets the following headers in the request: ``` X-Transfer-Status: true TE: trailers Transfer-Encoding: chunked ``` Then the response will used chunked encoding and indicate, on the last returned chunk, whether an error has occurred. Clients aware of these headers can now receive an error message from XRootD if there's an IO error in the middle of the response. This is expected to be useful in XCache use cases where failure mid-response is somewhat more common.
@djw8605 -- the intent is the |
Hi @bbockelm , Thanks for this :) I compiled everything and it works in the case the transfer succeeds. Out of curiosity, how do you manage to test that functionality ? I tried to fail the transfer but I get no information from the body/trailers that it fails, so probably I am missing something. |
@ccaffy - I test with this small patch to inject a fault:
Any reads after 64KB will fail (though, since reads are issued as 1MB chunks, the test file needs to be >1MB). Note that you'll need to add |
Additionally does some modest tidying of comments.
Hi @bbockelm , Thanks for the tips :) I managed to have the trailer working indeed. If I add your snippet of code, I indeed get the trailer:
Is it normal that I get a 200 OK response though ?
|
Yeah -- this is a typical issue in HTTP where the HTTP status has to be sent before the body. So, if there's any I/O error, it's too late to change the response status code. Currently, when an error happens mid-transfer, the server simply closes the TCP connection and the client reports something like "unexpected EOF". With this patch, if you ask for a status trailer, the client can get a useful error message (you might notice other PRs to improve error messages -- it's all related!). This has to be opt-in, however, to prevent unexpecting clients from interpreting the early exit as a success as the response no longer generates TCP-level problems. |
Alright, all things are clear now :) |
HTTP provides a response to include a "trailer" in addition to the better-known "header". If a user sets the following headers in the request:
Then the response will used chunked encoding and indicate, on the last returned chunk, whether an error has occurred.
Clients aware of these headers can now receive an error message from XRootD if there's an IO error in the middle of the response. This is expected to be useful in XCache use cases where failure mid-response is somewhat more common.