[master] ad8e8f8 Do not update mgt's mirrored VCL temp state on child temp state failures

Martin Blix Grydeland martin at varnish-software.com
Thu Mar 23 13:55:06 CET 2017


commit ad8e8f8e5ea4f14097825d4a4a23411e2ac222ae
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Wed Mar 22 14:17:17 2017 +0100

    Do not update mgt's mirrored VCL temp state on child temp state failures
    
    The child expects mgt to be consistent in its VCL state changes,
    e.g. not ask the child to 'use' a VCL that isn't warm. Not doing so
    will cause the child to assert (see asserts in
    cache_vcl.c:ccf_config_use). This could trigger because the mgt
    erranously would set its recorded temp regardless of the child's reply
    in mgt_vcl_setstate.
    
    This patch changes it to only record the new temp in mgt if the child
    replied success. If the child isn't running the new temp is always
    recorded.
    
    Slightly update v00044.vtc test case to reflect the need to update the
    state before restarting the child.

diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c
index 9f6672c..8849752 100644
--- a/bin/varnishd/mgt/mgt_vcl.c
+++ b/bin/varnishd/mgt/mgt_vcl.c
@@ -399,16 +399,15 @@ mgt_vcl_setstate(struct cli *cli, struct vclprog *vp, const char *vs)
 	if (vp->warm == warm)
 		return (0);
 
-	vp->warm = warm;
-
-	if (vp->warm == 0)
-		vp->go_cold = 0;
-
-	if (!MCH_Running())
+	if (!MCH_Running()) {
+		vp->warm = warm;
+		if (vp->warm == 0)
+			vp->go_cold = 0;
 		return (0);
+	}
 
 	i = mgt_cli_askchild(&status, &p, "vcl.state %s %d%s\n",
-	    vp->name, vp->warm, vp->state);
+	    vp->name, warm, vp->state);
 	if (i && cli != NULL) {
 		VCLI_SetResult(cli, status);
 		VCLI_Out(cli, "%s", p);
@@ -416,8 +415,15 @@ mgt_vcl_setstate(struct cli *cli, struct vclprog *vp, const char *vs)
 		MGT_Complain(C_ERR,
 		    "Please file ticket: VCL poker problem: "
 		    "'vcl.state %s %d%s' -> %03d '%s'",
-		    vp->name, vp->warm, vp->state, i, p);
+		    vp->name, warm, vp->state, i, p);
+	} else {
+		/* Success, update mgt's VCL state to reflect child's
+		   state */
+		vp->warm = warm;
+		if (vp->warm == 0)
+			vp->go_cold = 0;
 	}
+
 	free(p);
 	return (i);
 }
diff --git a/bin/varnishtest/tests/v00044.vtc b/bin/varnishtest/tests/v00044.vtc
index 26feae3..ff218f2 100644
--- a/bin/varnishtest/tests/v00044.vtc
+++ b/bin/varnishtest/tests/v00044.vtc
@@ -90,4 +90,5 @@ varnish v1 -clierr 300 "vcl.state vcl1 warm"
 
 # A warm-up failure can also fail a child start
 varnish v1 -cliok stop
+varnish v1 -cliok "vcl.state vcl1 warm"
 varnish v1 -clierr 300 start



More information about the varnish-commit mailing list