[master] 128fbe7 ban lurker should back off on seeing a busy object
Nils Goroll
nils.goroll at uplex.de
Thu May 17 15:59:23 UTC 2018
commit 128fbe7c88310c2c69c8f8312c6125ad12806ba6
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 52a3c79..f59b888 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;
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