Repository navigation
fix(metrics): expire metric-detail leases from the worker event loop - #1834
Merged
Merged
Conversation
The lease janitor ran only at the top of `Server::notify`, which only a worker command reaches. A lease whose owner disappeared (a crashed `sozu top`) therefore kept the worker's metric cardinality elevated past its TTL until the next control request, regardless of data-plane traffic. Move the janitor into `tick_metric_detail_leases` and call it once per event-loop iteration, before the response queue is flushed, as well as from `notify`. The loop wakes at least once per one-second poll timeout, so an abandoned lease is retired and its `lease_tick_expired` event is pushed within TTL + 5 s + one poll timeout with no further command. The new real-worker regression applies a one-second lease, keeps requests flowing, writes nothing more on the command channel and waits for the expiry event; it fails on the previous code. Fixes #1831 Signed-off-by: Florentin Dubois <[email protected]>
This was referenced Oct 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1831
Cause
CAUSE:
lib/src/server.rsServer::notify(the only productionlease_tickcall, reached only from command-channel messages) -> no event-loop path ran the janitor -> SYMPTOM: an abandonedSetMetricDetaillease outlived TTL + 5 s until the next worker command, regardless of data-plane traffic.Fix
tick_metric_detail_leases(now)(lib/src/server.rs), called once perServer::runiteration (beforesend_queue, so thelease_tick_expiredevent leaves on the same turn) and still fromnotify(keeps the single clock read shared withlease_apply).lease_tick_duestill gates the table walk to once per 5 s. The loop wakes at least once per 1 spoll_timeout, so expiry is bounded by TTL + 5 s + 1 s with no traffic and no command.lib/src/metrics/mod.rscomments,command.protolifecycle comment,doc/configure.md(the old "at most onettlwindow" was not true),doc/sozu-top.md, CHANGELOG (Unreleased / Fixed).Regression test
test_abandoned_lease_expires_without_a_command(e2e/src/tests/metrics_lifecycle_tests.rs): real worker, apply a 1 sDETAIL_BACKENDlease, then write nothing more on the command channel while HTTP requests keep flowing; passively read the channel until alease_tick_expiredMETRIC_DETAIL_CHANGEDevent (backend -> cluster) arrives within TTL + 8 s.bd19a78e(unfixed):test ... test_abandoned_lease_expires_without_a_command ... FAILED(stability check FAILED: iteration 1 of 3)test result: ok. 4 passed; 0 failed(allmetrics_lifecyclee2e,--features opentelemetry,splice,simd)Validation
cargo +nightly fmt --check-> exit 0cargo +1.93.1 clippy --all-features --all-targets --locked -- -D warnings-> exit 0RUSTDOCFLAGS="-D warnings" cargo +1.93.1 doc --no-deps --locked -p sozu-lib -p sozu-command-lib-> exit 0cargo +1.93.1 test -p sozu-command-lib --all-features --locked-> exit 0cargo +1.93.1 test -p sozu-lib --lib --all-features --locked-> 1591 passed, 1 failed:protocol::pipe::tests::splice_readable_eof_drains_kernel_pipe_bytes_before_closinghit its own host precondition guard (splice pipe capacity is 8192 bytes ... exceed fs.pipe-user-pages-soft (16384) ... this is a host limit, not a Sozu regression) on a shared, heavily loaded host; three isolated reruns: pass / same precondition / pass.pipe.rsis untouched here.python3 .github/scripts/check_doc_citations.py --root . --base origin/main-> exit 0#1828 (same-ID cluster incarnation) is deliberately not in this PR: it needs a design decision, see the issue.