Unverified Commit ba32426c authored by Nils Goroll's avatar Nils Goroll

fellow: Implement .happy VCL variable and add b_happy statistic bitfield

The .happy VCL variable now returns true only when the respective fellow
storage is open (has completed loading).

The b_happy VSL bitfield contains the happy state in individual bits,
updated at logbuffer_flush_interval. The least significant bit contains
the most recent happy state.

The semantics of the happy value are likely to change in the future.

Motivated by #66
parent ec72503b
......@@ -18,6 +18,15 @@ Version 1.0.0-rc3 (NEXT RELEASE)
fellow
======
* The ``.happy`` VCL variable of a fellow storage now returns ``true``
only when it is open (has completed loading).
The ``b_happy`` VSL bitfield contains the happy state in individual bits,
updated at logbuffer_flush_interval. The least significant bit contains
the most recent happy state.
The semantics of the happy value are likely to change in the future.
.. _#44: https://gitlab.com/uplex/varnish/slash/-/issues/44
* A workaround for an inconsistent Varnish-Cache API has been
......
......@@ -161,4 +161,19 @@
Note: This number is only approximate
.. varnish_vsc:: b_happy
:type: bitmap
:level: info
:format: bitmap
:oneliner: Storage is online
Whether or not the storage is online,
updated at logbuffer_flush_interval.
The happy value is 0 while the storage is loading or shutting
down and 1 while it is open. This will probably change when we
introduce error thresholds.
The bitmap has the most recent value in the least significant bit.
.. varnish_vsc_end:: fellow
......@@ -734,6 +734,9 @@ fellow_fd_update_stats(struct fellow_fd *ffd)
sz = buddy_space(buddy, 1);
ffd->stats->g_mem_space = sz;
ffd->stats->g_mem_bytes = buddy_size(buddy) - sz;
ffd->stats->b_happy <<= 1;
ffd->stats->b_happy |= !! fellow_is_open(ffd);
}
static void
......@@ -6858,6 +6861,7 @@ fellow_log_close(struct fellow_fd **ffdp)
fellow_logwatcher_fini(ffd);
ffd->phase = FP_FINI;
fellow_fd_update_stats(ffd);
fellow_logs_close(ffd);
BUDDY_POOL_FINI(ffd->logblk_pool);
......
......@@ -3069,6 +3069,16 @@ sfe_used_space(const struct stevedore *stv)
return ((VCL_BYTES)stvfe->stats->g_dsk_bytes);
}
static VCL_BOOL v_matchproto_(stv_var_happy)
sfe_happy(const struct stevedore *stv)
{
struct stvfe *stvfe;
CAST_OBJ_NOTNULL(stvfe, stv->priv, STVFE_MAGIC);
return (!!fellow_is_open(stvfe->ffd));
}
static void * v_matchproto_(storage_allocbuf_t)
sfe_allocbuf(struct worker *wrk, const struct stevedore *stv, size_t size,
uintptr_t *ppriv)
......@@ -3120,6 +3130,7 @@ static const struct stevedore sfemem_stevedore = {
.methods = &sfemem_methods,
.var_free_space = sfe_free_space,
.var_used_space = sfe_used_space,
.var_happy = sfe_happy,
.allocbuf = sfe_allocbuf,
.freebuf = sfe_freebuf,
};
......
......@@ -1271,6 +1271,14 @@ instance remains unusable. This is because free space on the storage
is implicitly defined as not being used by any object. Further
improvements of the initial load time might be possible, though.
To wait for cache loading to complete, the following methods can be
used:
* Wait for the ``FELLOW.<name>.b_happy`` bitfield from
:ref:`slash-counters(7)` to become non-zero.
* Wait for the ``storage.<name>.happy`` VCL variable to become true.
Cache loading can be observed using the folowing methods:
* By observing the :ref:`varnish-counters(7)` ``MAIN.n_objectcore``
......
......@@ -1187,6 +1187,14 @@ instance remains unusable. This is because free space on the storage
is implicitly defined as not being used by any object. Further
improvements of the initial load time might be possible, though.
To wait for cache loading to complete, the following methods can be
used:
* Wait for the ``FELLOW.<name>.b_happy`` bitfield from
:ref:`slash-counters(7)` to become non-zero.
* Wait for the ``storage.<name>.happy`` VCL variable to become true.
Cache loading can be observed using the folowing methods:
* By observing the :ref:`varnish-counters(7)` ``MAIN.n_objectcore``
......
......@@ -66,8 +66,9 @@ varnish v1 \
sub vcl_backend_error {
set beresp.status = 200;
set beresp.ttl = 1h;
set beresp.http.used_beresp = storage.fellow.used_space;
set beresp.http.free_beresp = storage.fellow.free_space;
set beresp.http.used_beresp = storage.fellow.used_space;
set beresp.http.free_beresp = storage.fellow.free_space;
set beresp.http.happy_beresp = storage.fellow.happy;
set beresp.storage = storage.fellow;
set beresp.http.storage = beresp.storage;
set beresp.http.source = "original";
......@@ -75,14 +76,16 @@ varnish v1 \
return (deliver);
}
sub vcl_backend_response {
set beresp.http.used_beresp = storage.fellow.used_space;
set beresp.http.free_beresp = storage.fellow.free_space;
set beresp.http.used_beresp = storage.fellow.used_space;
set beresp.http.free_beresp = storage.fellow.free_space;
set beresp.http.happy_beresp = storage.fellow.happy;
set beresp.storage = storage.fellow;
set beresp.http.storage = beresp.storage;
}
sub vcl_deliver {
set resp.http.used_deliver = storage.fellow.used_space;
set resp.http.free_deliver = storage.fellow.free_space;
set resp.http.used_deliver = storage.fellow.used_space;
set resp.http.free_deliver = storage.fellow.free_space;
set resp.http.happy_deliver = storage.fellow.happy;
}
} -start
......@@ -107,6 +110,8 @@ client c1 {
expect resp.http.used_deliver > 100000
expect resp.http.free_beresp > 100000000
expect resp.http.free_deliver > 100000000
expect resp.http.happy_beresp == true
expect resp.http.happy_deliver == true
txreq -url "/1"
rxresp
......@@ -131,6 +136,8 @@ client c1 {
expect resp.http.used_deliver > 100000
expect resp.http.free_beresp > 100000000
expect resp.http.free_deliver > 100000000
expect resp.http.happy_beresp == true
expect resp.http.happy_deliver == true
} -run
client c1 -repeat 16 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment