[6.0] f852f8774 ban lurker should back off on seeing a busy object

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Thu Aug 16 08:52:58 UTC 2018

commit f852f8774bf2f87474c5264ae9251fd29fca2911
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Thu May 17 17:40:53 2018 +0200

    ban lurker should back off on seeing a busy object
    HSH_Unbusy() calls BAN_NewObjCore() not holding the objhead
    lock, so the ban lurker may race and grab the ban mtx just
    after the new oc has been inserted, but the busy flag not
    yet cleared.
    While it would be correct to call BAN_NewObjCore() with the
    objhead mtx held, doing so would increase the pressure on the
    combined ban & objhead mtx.
    If the ban lurker encounters a busy object, we know that there
    must be an unbusy in progress and it would be wiser to rather
    back off in favor of the it.
    Fixes #2681

diff --git a/bin/varnishd/cache/cache_ban_lurker.c b/bin/varnishd/cache/cache_ban_lurker.c
index 52a3c79d4..f59b888ce 100644
--- a/bin/varnishd/cache/cache_ban_lurker.c
+++ b/bin/varnishd/cache/cache_ban_lurker.c
@@ -167,7 +167,7 @@ ban_lurker_getfirst(struct vsl_log *vsl, struct ban *bt)
 		oh = oc->objhead;
 		if (!Lck_Trylock(&oh->mtx)) {
-			if (oc->refcnt == 0) {
+			if (oc->refcnt == 0 || oc->flags & OC_F_BUSY) {
 			} else {

More information about the varnish-commit mailing list