[Varnish] #886: Ban-related crashes

Varnish varnish-bugs at varnish-cache.org
Mon May 2 14:01:25 CEST 2011


#886: Ban-related crashes
----------------------+-----------------------------------------------------
 Reporter:  kristian  |       Owner:                 
     Type:  defect    |      Status:  new            
 Priority:  normal    |   Milestone:  Varnish 3.0 dev
Component:  build     |     Version:  trunk          
 Severity:  normal    |    Keywords:                 
----------------------+-----------------------------------------------------

Comment(by kristian):

 As discussed, I've located the root of the problem.

 ban_check_object is accessed by through HSH_Lookup - which holds a lock on
 the objecthead, and through ban_lurker, which only holds a refcounter.
 When ban_check_object is accessed from both of these at the same time with
 the same oc, whichever finishes first will update the oc->ban in
 ban_check_object on cache_ban.c:471:

 {{{

 470         if (b == oc->ban) {     /* not banned */
 471                 oc->ban = b0;
 472                 o->ban_t = oc->ban->t0;
 473                 oc_updatemeta(oc);
 474                 return (0);
 475         } else {

 }}}

 This will confuse the other thread, which is looping through the ban,
 looking for the one that matches oc->ban (which has now been changed).

 While a lock on oh in the ban lurker is one solution, an other might be a
 temporary copy of oc->ban, but that still means you get two threads
 checking the same object, which is very much less than ideal (I don't see
 a use-case for two threads checking the same oc at the same time...).

-- 
Ticket URL: <http://varnish-cache.org/trac/ticket/886#comment:3>
Varnish <http://varnish-cache.org/>
The Varnish HTTP Accelerator




More information about the varnish-bugs mailing list