<div dir="ltr">bump</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 5, 2017 at 2:12 AM, Andrei <span dir="ltr"><<a href="mailto:lagged@gmail.com" target="_blank">lagged@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello everyone,<div><br></div><div>One of the backends we have configured, runs through an SSH tunnel which occasionally gets restarted. When the tunnel is restarted, Varnish is returning a 503 since it can't reach the backend for pages which would normally be cached (we force cache on the front page of the related site). I believe our grace implementation might be incorrect, as we would expect a grace period cache return instead of 503.</div><div><br></div><div><div>Our grace ttl is set to 21600 seconds based on a global variable:</div><div><br></div><div>sub vcl_backend_response {</div><div> set beresp.grace = std.duration(variable.global_<wbr>get("ttl_grace") + "s", 6h);</div><div>}</div><div><br></div><div>Our grace implementation in sub vcl_hit is:</div><div><br></div><div> sub vcl_hit {</div><div> # We have no fresh fish. Lets look at the stale ones.</div><div> if (std.healthy(req.backend_hint)<wbr>) {</div><div> # Backend is healthy. Limit age to 10s.</div><div> if (obj.ttl + 10s > 0s) {</div><div> #set req.http.grace = "normal(limited)";</div><div> std.log("OKHITDELIVER: obj.ttl:" + obj.ttl + " obj.keep: " + obj.keep + " obj.grace: " + obj.grace);</div><div> return (deliver);</div><div> } else {</div><div> # No candidate for grace. Fetch a fresh object.</div><div> std.log("No candidate for grace. Fetch a fresh object. obj.ttl:" + obj.ttl + " obj.keep: " + obj.keep + " obj.grace: " + obj.grace);</div><div> return(miss);</div><div> }</div><div> } else {</div><div> # backend is sick - use full grace</div><div> if (obj.ttl + obj.grace > 0s) {</div><div> #set req.http.grace = "full";</div><div> std.log("SICK DELIVERY: obj.hits: " + obj.hits + " obj.ttl:" + obj.ttl + " obj.keep: " + obj.keep + " obj.grace: " + obj.grace);</div><div> return (deliver);</div><div> } else {</div><div> # no graced object.</div><div> std.log("No graced object. obj.ttl:" + obj.ttl + " obj.keep: " + obj.keep + " obj.grace: " + obj.grace);</div><div> return (miss);</div><div> }</div><div> }</div><div><br></div><div> # fetch & deliver once we get the result</div><div> return (miss); # Dead code, keep as a safeguard</div><div> }</div><div><br></div><div><br></div><div>Occasionally we see:</div><div>- VCL_Log No candidate for grace. Fetch a fresh object. obj.ttl:-1369.659 obj.keep: 0.000 obj.grace: 21600.000</div><div><br></div><div>For the most part, it's:</div><div>- VCL_Log OKHITDELIVER: obj.ttl:26.872 obj.keep: 0.000 obj.grace: 21600.000</div><div><br></div><div>Are we setting the grace ttl too low perhaps?</div></div></div>
</blockquote></div><br></div>