[master] f7ca7c1ae Fix a bug in backend health state change timestamps.

Poul-Henning Kamp phk at FreeBSD.org
Tue Apr 20 21:10:13 UTC 2021


commit f7ca7c1aed56bb3e5c6253be6e51c8a766ac1da3
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Apr 20 20:50:36 2021 +0000

    Fix a bug in backend health state change timestamps.
    
    When admin commands control health, we report the timestamp of that
    override operation.
    
    When probing controls health, we report the timestamp of last
    probing state change.
    
    Otherwise, we report the timestamp of last admin health command.

diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 6ba15ffd8..3225e1f6d 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -688,17 +688,6 @@ VRT_delete_backend(VRT_CTX, VCL_BACKEND *dp)
 	// this is why we don't bust the director's magic number.
 }
 
-void
-VBE_SetHappy(const struct backend *be, uint64_t happy)
-{
-
-	CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC);
-	Lck_Lock(&backends_mtx);
-	if (be->vsc != NULL)
-		be->vsc->happy = happy;
-	Lck_Unlock(&backends_mtx);
-}
-
 /*---------------------------------------------------------------------*/
 
 void
diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h
index 7eabfebc3..536494f7b 100644
--- a/bin/varnishd/cache/cache_backend.h
+++ b/bin/varnishd/cache/cache_backend.h
@@ -79,9 +79,6 @@ struct backend {
  * Prototypes
  */
 
-/* cache_backend_cfg.c */
-void VBE_SetHappy(const struct backend *, uint64_t);
-
 /* cache_backend_probe.c */
 void VBP_Update_Backend(struct vbp_target *vt);
 void VBP_Insert(struct backend *b, struct vrt_backend_probe const *p,
diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c
index d1750ac63..18126cef2 100644
--- a/bin/varnishd/cache/cache_backend_probe.c
+++ b/bin/varnishd/cache/cache_backend_probe.c
@@ -54,6 +54,8 @@
 #include "cache_backend.h"
 #include "cache_conn_pool.h"
 
+#include "VSC_vbe.h"
+
 /* Default averaging rate, we want something pretty responsive */
 #define AVG_RATE			4
 
@@ -153,7 +155,6 @@ vbp_has_poked(struct vbp_target *vt)
 void
 VBP_Update_Backend(struct vbp_target *vt)
 {
-	const struct director *dir;
 	unsigned i = 0, chg;
 	char bits[10];
 
@@ -171,12 +172,6 @@ VBP_Update_Backend(struct vbp_target *vt)
 		return;
 	}
 
-	dir = vt->backend->director;
-	if (dir == NULL) {
-		Lck_Unlock(&vbp_mtx);
-		return;
-	}
-
 	i = (vt->good < vt->threshold);
 	chg = (i != vt->backend->sick);
 	vt->backend->sick = i;
@@ -187,12 +182,9 @@ VBP_Update_Backend(struct vbp_target *vt)
 	    i ? "sick" : "healthy", bits,
 	    vt->good, vt->threshold, vt->window,
 	    vt->last, vt->avg, vt->resp_buf);
-	VBE_SetHappy(vt->backend, vt->happy);
-
-	if (chg) {
+	vt->backend->vsc->happy = vt->happy;
+	if (chg)
 		vt->backend->changed = VTIM_real();
-		VRT_SetChanged(dir, vt->backend->changed);
-	}
 	Lck_Unlock(&vbp_mtx);
 }
 


More information about the varnish-commit mailing list