Mailing List Archive

#1808: Error in Varnish Request Flox
#1808: Error in Varnish Request Flox
-----------------------------+--------------------
Reporter: colas | Type: defect
Status: new | Priority: high
Milestone: Varnish 4.0-TP2 | Component: build
Version: trunk | Severity: normal
Keywords: |
-----------------------------+--------------------
Hello,

We use varnish-4.0.3 revision b8c4a34.
I think there are an error with the Varnish request Flow.

There a part of my conf


{{{
vcl 4.0;

import directors;
import std;
include "/etc/varnish/cfdoc.vcl";
include "/etc/varnish/devicedetect.vcl";

sub vcl_init {
new xxx = directors.round_robin();
xxx.add_backend(xxx1);

}

acl acl_reseaudoc {
...
"127.0.0.1";
}
sub vcl_recv {

call devicedetect; #On identifie les devices mobiles ou non
(include devicedetect.vcl)
if( client.ip ~ acl_reseaudoc) { # Force lookup if request is a
no-cache request from client
if (req.http.Pragma ~ "no-cache" && req.http.Cache-Control
~ "no-cache") {
if (req.method == "GET" ) { # On ne purge que sur
un GET, jamais sur un POST
ban("req.url == "+req.url); # Send the
"purge" command to the purge queue in a REGEXP form
return (synth(202, "Confirmation de purge
de la page"));
}
}
}

set req.backend_hint = xxx.backend(); # send all traffic to the
vdir director

set req.http.Via = "1.1 varnish-v4";
set req.http.grace = "none";
if (req.restarts == 0) {
if (req.http.X-Forwarded-For) { # set or append the
client.ip to X-Forwarded-For header
set req.http.X-Forwarded-For = req.http.X
-Forwarded-For + ", " + client.ip;
} else {
set req.http.X-Forwarded-For = client.ip;
}
}

#For debug
set req.http.X-Pass = "Debug-Pass";
return(pass);

....

return(hash);
}

# Called after vcl_recv to create a hash value for the request.
# This is used as a key to look up the object in Varnish.
sub vcl_hash {
set req.http.X-Pass = req.http.X-Pass+" hash";
hash_data(req.url);

if (req.http.host) {
hash_data(req.http.host);
} else {
hash_data(server.ip);
}

# On cache spécifiquement par type de device client
if (!req.url ~
"^[^?]*\.(bmp|bz2|js|doc|eot|flv|gif|tgz|gz|ico|jpeg|jpg|less|pdf|png|rtf|swf|txt|woff|xml|mp3|mp4)(\?.*)?$")
{
if (req.http.X-UA-Device ~ "mobile") {
hash_data("mobile");
}
}
}

sub vcl_hit {
set req.http.X-Pass = req.http.X-Pass+" hit";
# Called when a cache lookup is successful.
if (obj.ttl >= 0s) { # normal hit
return (deliver);
}
# We have no fresh fish. Lets look at the stale ones.
if (std.healthy(req.backend_hint)) {
# Backend is healthy. Limit age to 10s.
if (obj.ttl + 10s > 0s) {
set req.http.grace = "normal(limited)";
return (deliver);
} else {
# No candidate for grace. Fetch a fresh object.
return(fetch);
}
} else {
# backend is sick - use full grace
if (obj.ttl + obj.grace > 0s) {
# Object is in grace, deliver it
# Automatically triggers a background fetch
set req.http.grace = "full";
return (deliver);
} else {
# no graced object.
return (fetch);
}
}
}

sub vcl_miss {
set req.http.X-Pass = req.http.X-Pass+" miss";
return(fetch);
}

sub vcl_pass {
set req.http.X-Pass = req.http.X-Pass+" pass";

}

sub vcl_backend_fetch {

}}}

When I request a page I get this header :
X-Pass:Debug-Pass hash Pass

But if I read the documentation https://www.varnish-
software.com/book/4.0/chapters/VCL_Basics.html#detailed-varnish-request-
flow-for-the-client-worker-thread
If I make a return(pass) from vcl_recv I must bypass vcl_hash. With my
debug it's not the case.

I have :
vcl_recv => vcl_hash => vcl_pass

thank

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1808>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
Re: #1808: Error in Varnish Request Flox [ In reply to ]
#1808: Error in Varnish Request Flox
--------------------+------------------------------
Reporter: colas | Owner:
Type: defect | Status: closed
Priority: high | Milestone: Varnish 4.0-TP2
Component: build | Version: trunk
Severity: normal | Resolution: invalid
Keywords: |
--------------------+------------------------------
Changes (by fgsch):

* status: new => closed
* resolution: => invalid


Comment:

The code is correct, the documentation is not.

I've moved this to https://github.com/varnish/Varnish-Book/issues/70.

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1808#comment:1>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
Re: #1808: Error in Varnish Request Flox [ In reply to ]
#1808: Error in Varnish Request Flox
--------------------+------------------------------
Reporter: colas | Owner:
Type: defect | Status: closed
Priority: high | Milestone: Varnish 4.0-TP2
Component: build | Version: trunk
Severity: normal | Resolution: invalid
Keywords: |
--------------------+------------------------------

Comment (by colas):

Why is needed to hash the request if we want to pass it ? We don't need
to lookup.
I don't really understand.

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1808#comment:2>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
Re: #1808: Error in Varnish Request Flox [ In reply to ]
#1808: Error in Varnish Request Flox
--------------------+------------------------------
Reporter: colas | Owner:
Type: defect | Status: closed
Priority: high | Milestone: Varnish 4.0-TP2
Component: build | Version: trunk
Severity: normal | Resolution: invalid
Keywords: |
--------------------+------------------------------

Comment (by francisco):

We have improved the diagram in https://github.com/varnish/Varnish-
Book/blob/master/ui/img/detailed_fsm.svg.

VCL_hash_method is always called in vcl_recv. See line 701 in
https://github.com/varnish/Varnish-
Cache/blob/master/bin/varnishd/cache/cache_req_fsm.c#L701.

There are cases where the hash key of a cached object is required
regardless the next state. For example, the saintmode VMOD
https://github.com/varnish/libvmod-saintmode uses the hash key of an
object when maintaining the blacklist of sick backends. This list maps
specific objects to specific backends.

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1808#comment:3>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs