fluent icon indicating copy to clipboard operation
fluent copied to clipboard

Retries and body

Open jonasfj opened this issue 10 years ago • 2 comments

Seems broken if retries is used with body, as io.Reader won't rewind...

I haven't tried it... but that seems problematic... Maybe it's better to not support streams to avoid bugs.

Or am I missing something?

jonasfj avatar Feb 25 '16 17:02 jonasfj

Hi, I don't think that it'll be an issue because it's reusing the same request object, and if for some reason the server isn't reachable then it won't be able to send the request, therefore it won't read the io.Reader.

If you can post the code you using, it would be better.

Thanks.

lafikl avatar Feb 26 '16 21:02 lafikl

I haven't tried it yet... So feel free to close the issue :) The subtle timing dependent http/tcp issues can be very hard to reproduce... So I look for them before I use a library.

But, if the TCP connection is broken half way through streaming the request it seems all is lost... As io.Reader is mutable.

When hacking node, and dealing with TCP connection pooling which go does too... I happens that a TCP connection is kept alive, but really the remote end is dropped silently by server because of arbitrary timeout, etc. With some bad timing you'll be sending the request on to a TCP socket that's dead. The OS and by implication go won't know that the TCP connection is dead until it sends the next package.

It's standard practice for azure storage services to drop connections silently after 60 seconds. It feels bad, on the other hand it's really smart that it forces us to deal with the worst case scenario. As not doing so leads to unstable systems in any case.

Note: I don't have solution, short of simply not claiming to do retries for sending streams.. If sending binary things with retries, using []byte for seems like the only safe choice to me. Or io.ReadSeeker.

jonasfj avatar Feb 26 '16 23:02 jonasfj