[4.1] bd7c708 Do not update mgt's mirrored VCL temp state on child temp state failures
PÃ¥l Hermunn Johansen
hermunn at varnish-software.com
Wed Apr 5 12:03:05 CEST 2017
commit bd7c70805fada96b9c41ef99e604525e3734ca99
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.
Ref: https://github.com/varnishcache/varnish-cache/pull/2273
diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c
index 4c47730..9e9c53c 100644
--- a/bin/varnishd/mgt/mgt_vcl.c
+++ b/bin/varnishd/mgt/mgt_vcl.c
@@ -151,21 +151,26 @@ 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 (child_pid < 0)
+ if (child_pid < 0) {
+ 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) {
AN(cli);
- AN(vp->warm);
+ AN(warm);
VCLI_SetResult(cli, status);
VCLI_Out(cli, "%s", 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);
diff --git a/bin/varnishtest/tests/v00044.vtc b/bin/varnishtest/tests/v00044.vtc
index c056d6c..cc449aa 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