Getting Error 200 Guru Mediation Error on Purging using x-key
Closed this issue · 2 comments
I get the following response on purging using x-key
I have used the file storage backend using this :
varnishd -F -s disk=file,/var/lib/varnish/varnish_storage.bin,1G -f /etc/varnish/default.vcl -a:6085
and my purging logs are :
`
- << Request >> 4
- Begin req 3 rxreq
- Timestamp Start: 1678092742.493797 0.000000 0.000000
- Timestamp Req: 1678092742.493797 0.000000 0.000000
- VCL_use boot
- ReqStart 127.0.0.1 54232 a0
- ReqMethod PURGE
- ReqURL /
- ReqProtocol HTTP/1.1
- ReqHeader x-key: date
- ReqHeader User-Agent: PostmanRuntime/7.29.2
- ReqHeader Accept: /
- ReqHeader Postman-Token: ca71ae56-5438-497b-b7f7-165f64ce98f4
- ReqHeader Host: localhost:8086
- ReqHeader Accept-Encoding: gzip, deflate, br
- ReqHeader Connection: keep-alive
- ReqHeader Content-Length: 0
- ReqHeader X-Forwarded-For: 127.0.0.1
- ReqHeader Via: 1.1 fa063941 (Varnish/7.2)
- VCL_call RECV
- VCL_Log Aadarsh
- ReqHeader n-gone: 0
- VCL_return synth
- ReqUnset Accept-Encoding: gzip, deflate, br
- ReqHeader Accept-Encoding: gzip
- VCL_call HASH
- VCL_Log cookie data in hash function =
- VCL_return lookup
- RespProtocol HTTP/1.1
- RespStatus 200
- RespReason Invalidated 0 objects
- RespHeader Date: Mon, 06 Mar 2023 08:52:22 GMT
- RespHeader Server: Varnish
- RespHeader X-Varnish: 4
- VCL_call SYNTH
- RespHeader Content-Type: text/html; charset=utf-8
- RespHeader Retry-After: 5
- VCL_return deliver
- Timestamp Process: 1678092742.493831 0.000033 0.000033
- RespHeader Content-Length: 281
- Storage malloc Transient
- Filters
- RespHeader Connection: keep-alive
- Timestamp Resp: 1678092742.493866 0.000069 0.000035
- ReqAcct 235 0 235 207 281 488
- End
`
Don't know why my storage is malloc Transient in this case when I am using file type storage backend could be the source of the issue
my VCL file is
`
sub vcl_recv {
if (req.method == "PURGE") {
if (req.http.x-key) {
set req.http.n-gone = xkey.purge(req.http.x-key);
# or: set req.http.n-gone = xkey.softpurge(req.http.xkey)
return (synth(200, "Invalidated "+req.http.n-gone+" objects"));
} else {
return (purge);
}
}
}
sub vcl_backend_response {
// set beresp.storage = disk;
set beresp.ttl = 0s;
if(bereq.url ~ "date"){
unset beresp.http.Cache-Control;
set beresp.http.Cache-Control = "public";
set beresp.ttl = 10m;
set beresp.http.x-key = "date";
std.log("setting cache-control");
}
}
`
hi @Aadarsh-Verma ,
this doesn't look like a bug so I'll close this.
in short:
- you are generating a synthetic response with
synth(200, ...)
(either directly, or via the defaultvcl_purge
(https://github.com/varnishcache/varnish-cache/blob/master/bin/varnishd/builtin.vcl#L133-L136)), and those are held in the ~transient` storage (https://varnish-cache.org/docs/trunk/users-guide/storage-backends.html#transient-storage) - the
Guru meditation
is created by the built-invcl_synth
subroutine (https://github.com/varnishcache/varnish-cache/blob/master/bin/varnishd/builtin.vcl#L173-L191)