[Varnish] #1180: Restart in vcl_miss increases miss count even for hits and passes.

Varnish varnish-bugs at varnish-cache.org
Tue Jul 31 23:58:22 CEST 2012

#1180: Restart in vcl_miss increases miss count even for hits and passes.
 Reporter:  david  |       Type:  defect
   Status:  new    |   Priority:  normal
Milestone:         |  Component:  build
  Version:  3.0.2  |   Severity:  normal
 Keywords:         |

 I believe I have located another bug in Varnish Cache. This is similar to
 and follows Trac # 965.

 My code hashes all requests based on client.ip to see if the user has a
 cached ban on their IP. If they do not, we restart the request and hash
 normally. The problem with this is that I end up with far more
 cache_misses than I had requests:

 client_conn                749         6.35 Client connections accepted

 client_req                 749         6.35 Client requests received

 cache_hit                   75         0.64 Cache hits

 cache_hitpass                0         0.00 Cache hits for pass

 cache_miss                1365        11.57 Cache misses

 s_pass                      52         0.44 Total pass

 This is the VCL that reproduces the problem:

 sub vcl_recv {
     if (req.http.X-LJ-Banned ~ "sysban-ip") {
         return (lookup);
     elseif (req.restarts == 0) {
         set req.http.X-LJ-Banned = "check";
         return (lookup);

 sub vcl_hash {
     if (req.http.X-LJ-Banned && req.restarts > 0) {
         return (hash);

 sub vcl_miss {
   if (req.http.X-LJ-Banned == "check") {
       remove req.http.X-LJ-Banned;
       error 988;

 sub vcl_error {
   if (obj.status == 988) {
     return (restart);

 I left out the vcl_fetch code since it is not required to reproduce this
 problem. I assume showing more cache misses than the total number of
 requests is not intentional and is something that should be fixed.

 Warm Regards,
 David Newhall

Ticket URL: <https://www.varnish-cache.org/trac/ticket/1180>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

More information about the varnish-bugs mailing list