[Varnish] #652: restart; loses POST data

Varnish varnish-bugs at projects.linpro.no
Fri Feb 26 10:42:31 CET 2010


#652: restart; loses POST data
---------------------+------------------------------------------------------
 Reporter:  jespern  |        Type:  defect
   Status:  new      |    Priority:  normal
Milestone:           |   Component:  build 
  Version:  trunk    |    Severity:  normal
 Keywords:           |  
---------------------+------------------------------------------------------
 We're using a trick to emulate internal redirects, involving 'restart;' in
 vcl_fetch. Basically our 'default' backend is a small HTTP application
 that sets a header called 'Select-Shard', and varnish will restart the
 request with another backend selected.

 Unfortunately, once the request re-enters vcl_recv, if the request is a
 POST, the body will be gone.

 I believe anything involving 'restart;' suffers from this, from what I can
 understand after discussing this on IRC.

 Here's the VCL:

 {{{
 backend default {
         .host = "127.0.0.1";
         .port = "8089";
 }

 backend web {
         .host = "127.0.0.1";
         .port = "8000";
 }

 backend web2 {
         .host = "127.0.0.1";
         .port = "8001";
 }

 director www_dir round-robin {
         { .backend = web; }
 #       { .backend = web2; }
 }

 sub vcl_recv {
         if (req.http.Select-Shard == "web") {
                 set req.backend = web;
         } elsif (req.http.Select-Shard == "web2") {
                 set req.backend = web2;
         } elsif (req.http.Select-Shard == "rr") {
                 set req.backend = www_dir;
         }
 }

 sub vcl_fetch {
         if (obj.http.Select-Shard) {
                 set req.http.Select-Shard = obj.http.Select-Shard;
                 restart;
         }
 }
 }}}

-- 
Ticket URL: <http://varnish-cache.org/ticket/652>
Varnish <http://varnish.projects.linpro.no/>
The Varnish HTTP Accelerator


More information about the varnish-bugs mailing list