Skip to content
This repository was archived by the owner on Feb 16, 2026. It is now read-only.

cache_req{,_fsm}: Add resp.storage control over synth body's storage#4358

Open
nigoroll wants to merge 198 commits intovarnishcache:masterfrom
nigoroll:sync_resp.storage
Open

cache_req{,_fsm}: Add resp.storage control over synth body's storage#4358
nigoroll wants to merge 198 commits intovarnishcache:masterfrom
nigoroll:sync_resp.storage

Conversation

@nigoroll
Copy link
Copy Markdown
Member

@nigoroll nigoroll commented Jul 8, 2025

draft PR of WIP for early review / feedback opportunities.

Next steps (planned, do not nail me down on this)


This adds the vcl variable resp.storage, available from vcl_synth {} to control which storage the synth response body gets created on.

Rather than just remembering the stroage for use after VCL has returned, we actually create an object on it when the variable changes.

This is the first step towards #4344

@nigoroll
Copy link
Copy Markdown
Member Author

Bugwash: Does Resp_l_storage() exist for a could reason or could we use just the VRT_ functions?

@nigoroll
Copy link
Copy Markdown
Member Author

Bugwash: Does Resp_l_storage() exist for a could reason or could we use just the VRT_ functions?

The answer is that we do not have a VRT_CTX in cnt_synth, because we only create it in the "fsm wrapper" VCL_*_method, but we need to call the "set the default storage" function from cnt_synth in case VCL has not set (or unset) the storage.

@nigoroll nigoroll marked this pull request as ready for review November 10, 2025 15:07
nigoroll and others added 22 commits February 16, 2026 08:31
This reverts commit 0038dd1.
When calling out from configure to python to check compiler flags, make
output from wflags.py consistent with the rest of autotools output
rather than printing scary compiler errors.
sed -i 's:/github.com/varnishcache/varnish-cache/pull:/code.vinyl-cache.org/vinyl-cache/vinyl-cache/pulls:g' $(git grep -l github.com/varnishcache/varnish-cache/pull)

And then manually edited two URLs pointing to individual comments
When translating VCL-to-C, VCL_BOOL values are
translated verbatim, the stdbool.h file is not
included in vgc.c. On Debian this causes the
following error:
```
**** v1    CLI RX|Message from C-compiler:
**** v1    CLI RX|vgc.c: In function 'VGC_function_vcl_init':
**** v1    CLI RX|vgc.c:4402:26: error: 'false' undeclared (first use in this function)
**** v1    CLI RX| 4402 |           .hidevclname = false,
**** v1    CLI RX|      |                          ^~~~~
**** v1    CLI RX|vgc.c:702:1: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
**** v1    CLI RX|  701 | #include <stddef.h>             // NULL, size_t
**** v1    CLI RX|  +++ |+#include <stdbool.h>
**** v1    CLI RX|  702 | #include <stdint.h>             // [u]int%d_t
**** v1    CLI RX|vgc.c:4402:26: note: each undeclared identifier is reported only once for each function it appears in
**** v1    CLI RX| 4402 |           .hidevclname = false,
**** v1    CLI RX|[1 lines truncated]
**** v1    CLI RX|Running C-compiler failed, exited with 1
**** v1    CLI RX|VCL compilation failed
```
This commit fixes this by translating the boolean
values (true/false) to int values (0/1).
Since the strings are already checked to be valid
identifiers we only check for the first letter
in order to discriminate true from false.
sed -i 's:/github.com/varnishcache/varnish-cache/blob/master/doc/changes.rst:/code.vinyl-cache.org/vinyl-cache/vinyl-cache/src/branch/main/doc/changes.rst:g' $(git grep -l github.com/varnishcache/varnish-cache)

It is a bit annoying that forgejo does not render RST, so the document is
essentially displayed as raw text.

Because changes.rst is the basis for release docs and those are going to stay
rst in sphinx, we can not sensibly migrate.

We could check in an md copy, but that is also not nice...
sed -i 's:/github.com/varnishcache/varnish-cache:/code.vinyl-cache.org/vinyl-cache/vinyl-cache:g' $(git grep -l github.com/varnishcache/varnish-cache)
sed -i 's:/github.com/varnishcache/pkg-varnish-cache:/code.vinyl-cache.org/vinyl-cache/pkg-vinyl-cache:g' $(git grep -l github.com/varnishcache/)
The change broke literal default values, as exposed by m0.vtc

Identified using git bisect

Ref 2d5312c
Ref #4452
The Vinyl Asynchronous Iterator (basically the code sending data to the client)
requests data (by pulling into a vscarab), but the called filter or storage
engine might not have it ready. In this case, -EAGAIN is returned to signal to
the iterator "try again later", because no component of the VAI path must block
ever.

For the case of the storage engine returning -EAGAIN, we already have the
notification callback provided by the iterator, which the storage engine must
call when it either has data or an error to return. Upon reception of the
notification, the iterator has to call into VDPIO and, consequently, ObjVAI
again and pull the new state.

None of this is new, but VDPs might also encounter situations where they can not
serve the data _yet_, in which case they also return -EAGAIN. But they had,
until now, no way to trigger a notification.

So we add the simple mechanics of a notification function at the ObjVAI, Object
and VPDIO layer, ultimately only leading to the notification callback registered
by the iterator being called.

We involve the storage engine because it might be interested to know when a VDP
"above it" becomes ready to send data again, for example to start reading ahead.
I added a branch protection rule to forbid force-pushes.
nigoroll and others added 29 commits March 16, 2026 11:13
to keep in sync with the homepage
Partially reverts 879c9b3

This restores the option to set/keep localstatedir at ${prefix}/var and still
have VINYL_STATE_DIR in {localstatedir}/lib/vinyl-cache, and not /var/run.

Consequently, this fixes running vinyld with default options on systems where
/var/run is mounted noexec (e.g. Debian) and restores the possibility to wholly
contain the installation under ${prefix}.

The patch does not use ${sharedstatedir}, because its default is ${prefix}/com

Closes #4477
If VINYL_STATE_DIR could only be set to ${localstatedir}/lib/vinyl-cache, we can
not (reliably, without additional lifecycle management) use an ephemeral
${localstatedir} like /dev/shm, simply because we create a subdirectory of
VINYL_STATE_DIR for the actual state (see -n argument, defaulting to vinyld),
and ${localstatedir}/lib/vinyl-cache might not exist.

Adding recursive mkdir code to vinyld could also solve the problem, but would
add the complication of which permissions to recursively create directories
with, in particular considering that vinyld may or may not be started with
elevated privileges.

To avoid all these complications, we add a configure argument to directly set
VINYL_STATE_DIR

Related to #4477
When vsl_buffer was increased from 4k to 16k in 8869801, three
tests with small workspaces were updated to explicitly set vsl_buffer
to 4k. This test was missed, causing panics in VBO_GetBusyObj() and
Req_New() when the 16k VSL buffer exceeds the 12000-byte pool
allocation.

The bug has been latent since July 2021 but was masked by mempool
item reuse: the param.set happens mid-test after pool items have
already been allocated at 96k, and those larger items keep getting
recycled. A fresh 12k allocation (which deterministically panics)
only occurs when the guard thread injects a new item before old ones
are reused, which is timing-dependent.

The recent move to github actions is likely the thing that made this
visible.

Committer edit: Adjusted to Vinyl Cache

Fixes: varnish/varnish#8
Fixes: varnish/varnish#9
Until now we kept failed objects momentarily on the LRU. This is wasteful,
because they never get inserted into EXP (which happens via HSH_Unbusy() ->
EXP_Insert), and as such will be removed from cache when the last reference goes
away.

Why is this change correct?

- in HSH_Lookup(), we explicitly skip OC_F_FAILED
- the only place where OC_F_FAILED can be gained is HSH_Fail()
- HSH_Fail() asserts that the object is still busy
- LRU_Add() gets called via HSH_DerefBoc() -> ObjBocDone() when
  the boc's last reference goes away
(And make the FreeBSD runner -j2)
This adds the vcl variable resp.storage, available from vcl_synth {} to control
which storage the synth response body gets created on.

Rather than just remembering the stroage for use after VCL has returned, we
actually create an object on it when the variable changes.

This is the first step towards varnishcache#4344
@nigoroll nigoroll force-pushed the sync_resp.storage branch from 0766d24 to dc4ac44 Compare April 8, 2026 13:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants