[4.1] 7906a41 ban lurker should back off on seeing a busy object

PÃ¥l Hermunn Johansen hermunn at varnish-software.com
Fri Jun 1 09:40:25 UTC 2018


commit 7906a41782a39a407f41d831da05326c4b2d225c
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 ada0c05..4465ed2 100644
--- a/bin/varnishd/cache/cache_ban_lurker.c
+++ b/bin/varnishd/cache/cache_ban_lurker.c
@@ -108,7 +108,7 @@ ban_lurker_getfirst(struct vsl_log *vsl, struct ban *bt)
 		oh = oc->objhead;
 		CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
 		if (!Lck_Trylock(&oh->mtx)) {
-			if (oc->refcnt == 0) {
+			if (oc->refcnt == 0 || oc->flags & OC_F_BUSY) {
 				Lck_Unlock(&oh->mtx);
 			} else {
 				/*


More information about the varnish-commit mailing list