[master] 1970515d8 cache_fetch: make max_retries consistent during the busyobj lifetime
Nils Goroll
nils.goroll at uplex.de
Sun Feb 9 18:41:06 UTC 2025
commit 1970515d8a4ae770cb610c98a155d456fe4e42e9
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Sun Feb 9 19:35:09 2025 +0100
cache_fetch: make max_retries consistent during the busyobj lifetime
There is no assertion to be hit like in the previous commit, but we might still
want to avoid running in a situation where the number of retries "suddenly"
changes. For example, we could fail for "too many retries", end up in v_b_e {}
and be able to retry from there, if the cache parameter was changed at just the
right time.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 1be031eb8..ffa3d8577 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -383,6 +383,7 @@ struct busyobj {
char *end;
+ unsigned max_retries;
unsigned retries;
struct req *req;
struct sess *sp;
diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c
index 5293186fe..42332ecd7 100644
--- a/bin/varnishd/cache/cache_busyobj.c
+++ b/bin/varnishd/cache/cache_busyobj.c
@@ -72,6 +72,7 @@ VBO_GetBusyObj(const struct worker *wrk, const struct req *req)
XXXAN(bo);
bo->magic = BUSYOBJ_MAGIC;
bo->end = (char *)bo + sz;
+ bo->max_retries = cache_param->max_retries;
p = (void*)(bo + 1);
p = (void*)PRNDUP(p);
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index dc842208b..196817512 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -530,7 +530,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
bo->htc->doclose = SC_RESP_CLOSE;
vbf_cleanup(bo);
- if (bo->retries++ < cache_param->max_retries)
+ if (bo->retries++ < bo->max_retries)
return (F_STP_RETRY);
VSLb(bo->vsl, SLT_VCL_Error,
@@ -995,7 +995,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
if (wrk->vpi->handling == VCL_RET_RETRY) {
VSB_destroy(&synth_body);
- if (bo->retries++ < cache_param->max_retries)
+ if (bo->retries++ < bo->max_retries)
return (F_STP_RETRY);
VSLb(bo->vsl, SLT_VCL_Error, "Too many retries, failing");
return (F_STP_FAIL);
More information about the varnish-commit
mailing list