[Varnish] #749: 503 if web server closes connection too soon.

Varnish varnish-bugs at varnish-cache.org
Thu Aug 5 10:11:27 CEST 2010

#749: 503 if web server closes connection too soon.
 Reporter:  Dan          |       Owner:  phk  
     Type:  enhancement  |      Status:  new  
 Priority:  normal       |   Milestone:       
Component:  varnishd     |     Version:  trunk
 Severity:  normal       |    Keywords:       
 I have a webserver, that will per definition misbehave.
 This is because its running apache2 with mpm-itk, a worker module that
 does setuid per apache fork, based on Host-header.

 This results in one caveat. If you try to access another virtualhost on
 the same TCP connection, mpm-itk will drop its connection after you've
 transmitted the header, since youve changed the host-header.

 Aparantly not a problem for browsers, but as soon as i stick varnishd in
 front of a server with 2 vhosts, i get 503 every time i alternate between
 the vhosts.

 I'd love a config option to enable something that catches this sudden
 disconnect and works around it.

 I can think of 3 ways to work around this:
  1. Open a TCP connection per src-ip/vhost pair
  2. always close TCP-connection after each fetch
  3. automatic retry on fetch error.

 Option 1 is probably most efficient. 2 would be very inefficient and 3, a
 bit more efficient than 2, and sounds really easy to do :)

 The following small patch has solves the problem for me (option 3).
 --- /home/dan/cache_center.c    2010-07-24 19:58:03.000000000 +0200
 +++ bin/varnishd/cache_center.c 2010-07-24 20:03:30.000000000 +0200
 @@ -439,6 +439,12 @@

         i = FetchHdr(sp);

 +       /* Retry (once) if fetching headers failed */
 +       if (i) {
 +               WSP(sp, SLT_FetchError, "Error while fetching header,
 +               i = FetchHdr(sp);
 +       }
          * Save a copy before it might get mangled in VCL.  When it comes
          * dealing with the body, we want to see the unadultered headers.

Ticket URL: <http://www.varnish-cache.org/ticket/749>
Varnish <http://varnish-cache.org/>
The Varnish HTTP Accelerator

More information about the varnish-bugs mailing list