Hi all, Am 05.12.2013 22:03, schrieb Yann Ylavic: > I'm not talking about retrying requests but retrying writing on the > socket after trying to "re-"open a connection. When mod_proxy tries > to forward the client request to the backends and encounters a > closed connection due to the described race condition it will fail > back to the client. Instead, I suggest trying to re-open the > connection once and then either send the client request over that > connection or go back to the client with an error. No double-sending > requests anywhere. > > I must be missing something. > > When mod_proxy encounters a closed (reused) connection while forwarding > the client's request, it has just sent the request once, right?
That depends on the actual state. What Thomas is talking about (I know because I worked with him on the same product he is referring to here) is the state where you have everything in place to send out the next request headers on a connection that was established by a previous request and that was kept open using HTTP Keep-Alive. Let me stress the fact that in this state you haven't sent a single bit of the current request over the wire yet. Now, if trying to send the first bytes of the request immediately fails because the socket isn't connected anymore (e.g. EPIPE), you *know* that exactly *none* bits of your current request reached the server. For this reason it should be safe to retry by establishing a new connection to the server and to try to send the request again over the newly established connection. To avoid an endless retry loop, you certainly should do this retry approach only once per request. In the sense of getting the reverse proxy request correctly processed by the backend server, this approach *does* fix the keep-alive race condition issue where the server closes the backend connection because it sees no (new) client request for too long time -- IIRC this is what this discussion started with. I hope I could shed some more some light on this issue and on the idea how to possibly tackle it in Apache httpd. Regards, Micha
