[Varnish] #265: Implement nuke option to invalidate all variants of an object

Varnish varnish-bugs at projects.linpro.no
Tue Jul 1 16:35:33 CEST 2008


#265: Implement nuke option to invalidate all variants of an object
-------------------------+--------------------------------------------------
 Reporter:  sky          |       Owner:  phk  
     Type:  enhancement  |      Status:  new  
 Priority:  normal       |   Milestone:       
Component:  varnishd     |     Version:  trunk
 Severity:  normal       |    Keywords:       
-------------------------+--------------------------------------------------
 This implements a new return value from vcl_hit called nuke.

 It will mangle the hash value of the object (per suggestion from phk), so
 future lookups won't find it, instead of locking all children and
 invalidating them

 {{{
 -bash-3.1$ svn diff
 Index: include/vcl_returns.h
 ===================================================================
 --- include/vcl_returns.h       (revision 2871)
 +++ include/vcl_returns.h       (working copy)
 @@ -20,6 +20,7 @@
  VCL_RET_MAC(discard, DISCARD, (1 << 8), 8)
  VCL_RET_MAC(keep, KEEP, (1 << 9), 9)
  VCL_RET_MAC(restart, RESTART, (1 << 10), 10)
 +VCL_RET_MAC(nuke, NUKE, (1 << 11), 11)
  #else
  #define VCL_RET_ERROR  (1 << 0)
  #define VCL_RET_LOOKUP  (1 << 1)
 @@ -32,7 +33,8 @@
  #define VCL_RET_DISCARD  (1 << 8)
  #define VCL_RET_KEEP  (1 << 9)
  #define VCL_RET_RESTART  (1 << 10)
 -#define VCL_RET_MAX 11
 +#define VCL_RET_NUKE  (1 << 11)
 +#define VCL_RET_MAX 12
  #endif

  #ifdef VCL_MET_MAC
 @@ -41,7 +43,7 @@
  VCL_MET_MAC(pass,PASS,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS))
  VCL_MET_MAC(hash,HASH,(VCL_RET_HASH))
 VCL_MET_MAC(miss,MISS,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_FETCH))
 -VCL_MET_MAC(hit,HIT,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_DELIVER))
 +VCL_MET_MAC(hit,HIT,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_DELIVER|VCL_RET_NUKE))
 VCL_MET_MAC(fetch,FETCH,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_INSERT))
 VCL_MET_MAC(deliver,DELIVER,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_DELIVER))
  VCL_MET_MAC(prefetch,PREFETCH,(VCL_RET_FETCH|VCL_RET_PASS))
 Index: lib/libvcl/vcc_gen_fixed_token.tcl
 ===================================================================
 --- lib/libvcl/vcc_gen_fixed_token.tcl  (revision 2871)
 +++ lib/libvcl/vcc_gen_fixed_token.tcl  (working copy)
 @@ -39,7 +39,7 @@
         {pass           {error restart pass}}
         {hash           {hash}}
         {miss           {error restart pass fetch}}
 -       {hit            {error restart pass deliver}}
 +       {hit            {error restart pass deliver nuke}}
         {fetch          {error restart pass insert}}
         {deliver        {error restart deliver}}
         {prefetch       {fetch pass}}
 @@ -61,6 +61,7 @@
         discard
         keep
         restart
 +       nuke
  }

  # Language keywords
 Index: lib/libvcl/vcc_fixed_token.c
 ===================================================================
 --- lib/libvcl/vcc_fixed_token.c        (revision 2871)
 +++ lib/libvcl/vcc_fixed_token.c        (working copy)
 @@ -303,6 +303,7 @@
         vsb_cat(sb, "#define VCL_RET_DISCARD  (1 << 8)\n");
         vsb_cat(sb, "#define VCL_RET_KEEP  (1 << 9)\n");
         vsb_cat(sb, "#define VCL_RET_RESTART  (1 << 10)\n");
 +       vsb_cat(sb, "#define VCL_RET_NUKE  (1 << 11)\n");
         vsb_cat(sb, "/*\n");
         vsb_cat(sb, " * $Id$\n");
         vsb_cat(sb, " *\n");
 Index: bin/varnishd/cache_center.c
 ===================================================================
 --- bin/varnishd/cache_center.c (revision 2871)
 +++ bin/varnishd/cache_center.c (working copy)
 @@ -491,6 +491,18 @@
                 return (0);
         }

 +       if (sp->handling == VCL_RET_NUKE) {
 +               /* kill all versions of this object
 +               then go on to pass
 +               we do this by mangling the first part of the string
 +               so we dont have to find and lock all objects */
 +               LOCK(&sp->obj->objhead->mtx);
 +               sp->obj->objhead->hash[0] = "\n";
 +               UNLOCK(&sp->obj->objhead->mtx);
 +               sp->handling = VCL_RET_PASS;
 +       }
 +
 +
         /* Drop our object, we won't need it */
         HSH_Deref(sp->obj);
         sp->obj = NULL;
 }}}

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


More information about the varnish-bugs mailing list