[master] 68a04aecd Don't remove VSM_FLAG_CLUSTER too early

Martin Blix Grydeland martin at varnish-software.com
Mon Sep 9 08:23:06 UTC 2019


commit 68a04aecdee977f5fac153779b65945feb201d04
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Fri Aug 30 15:18:46 2019 +0200

    Don't remove VSM_FLAG_CLUSTER too early
    
    If a segment will be marked stale, it should not have its cluster flag
    removed until its actually deleted.
    
    This problem was observed in varnishtest as an assert. What happened was
    that a VSM_Map() was executed on a stale segment inside a cluster, which
    caused an assert when the cluster segment it pointed to was no longer
    marked VSM_FLAG_CLUSTER.

diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c
index 2bd93f449..6454b06b1 100644
--- a/lib/libvarnishapi/vsm.c
+++ b/lib/libvarnishapi/vsm.c
@@ -253,11 +253,6 @@ vsm_delseg(struct vsm_seg *vg, int refsok)
 
 	CHECK_OBJ_NOTNULL(vg, VSM_SEG_MAGIC);
 
-	if (vg->flags & VSM_FLAG_CLUSTER) {
-		vg->flags &= ~VSM_FLAG_CLUSTER;
-		VTAILQ_REMOVE(&vg->set->clusters, vg, clist);
-	}
-
 	if (refsok && vg->refs) {
 		AZ(vg->flags & VSM_FLAG_STALE);
 		vg->flags |= VSM_FLAG_STALE;
@@ -269,6 +264,11 @@ vsm_delseg(struct vsm_seg *vg, int refsok)
 	if (vg->s != NULL)
 		vsm_unmapseg(vg);
 
+	if (vg->flags & VSM_FLAG_CLUSTER) {
+		vg->flags &= ~VSM_FLAG_CLUSTER;
+		VTAILQ_REMOVE(&vg->set->clusters, vg, clist);
+	}
+
 	if (vg->flags & VSM_FLAG_STALE)
 		VTAILQ_REMOVE(&vg->set->stale, vg, list);
 	else


More information about the varnish-commit mailing list