Repository navigation
Description
Measured against origin/main at fa11f549c02722a378b983a0b3cb716187f54e14.
e2e/src/tests/mux_tests.rs opens with a header listing P0: close() stream cleanup (http.active_requests gauge leak) among the properties it covers, and carries three tests named
after that gauge:
- test 15,
H1 idle timeout does not underflow active_requests gauge - test 16,
H1 malformed request does not underflow active_requests gauge - test 17,
H1 100 Continue does not double-decrement active_requests gauge
None of the three reads the gauge. active_requests occurs 11 times across all of e2e/, and
every one of them is a comment or a test-title string — there is no gauge read anywhere in the
end-to-end suite. The eleventh, h2_correctness_tests.rs:202, is a doc comment naming
Backend::active_requests, the load-balancer field, which is a different thing.
Test 15 opens five connections, waits for 408s, then asserts that a later request answers 200. That
assertion holds identically whether or not the gauge underflowed.
Why the tests cannot fail
AggregatedMetric::update clamps a negative GaugeAdd to exactly 0 rather than wrapping, and logs
an error!. The clamp is deliberate and correct — a clear()/remove during live traffic can
legitimately drive a paired decrement below a fresh-zero baseline. But it means an unbalanced gauge
is not observable from its value alone:
correct 0 -> 1 -> 0
missing increment 0 -> 0 -> 0 indistinguishable from balanced
missing decrement 0 -> 1 -> 1 observable only while the request is in flight
A test that samples the gauge before and after a request reads 0 and 0 in both the correct and
the missing-increment case. The only sampling that distinguishes them holds the request open at the
backend and reads the gauge in flight.
So the three tests are not merely thin: the property they are named for is one that the shape they
use cannot express. They were written for a fix whose regression they therefore never witnessed.
The balance they would have to assert
names::http::ACTIVE_REQUESTS has three +1 sites and one -1:
h1.rs:524 |
+1, H1 readable path |
h1.rs:874 |
+1, H1 writable path, pipelined request |
h2.rs:6055 |
+1, H2 |
stream.rs:670 |
-1, inside Stream::generate_access_log |
The decrement is shared: generate_access_log is called from three sites in h1.rs, four in
h2.rs and one in mod.rs. Stream::request_counted is the idempotency flag pairing each -1
with its +1, asserted at stream.rs:364 and stream.rs:403.
mod.rs:1011, in the Recycle branch of Context::create_stream, resets request_counted to
false without a decrement. That is not a leak — a slot only reaches Recycle after
generate_access_log has already decremented and cleared — but it is the one site that clears the
flag without emitting anything, and it should stay the only one.
What a replacement looks like
In-flight sampling, one test per path, each failing on a different assertion so the two halves
stay distinguishable:
- hold a request open at the backend, assert the gauge is
1while it is in flight — this is the
assertion a missing+1breaks; - release it, assert the gauge returns to
0— this is the assertion a missing-1breaks.
H1 has two upper halves, so an H1 test covers the one its scenario plays and says which, rather
than leaving the other looking covered.
Each replacement must be seen red by removing one half of one path on otherwise unmodified
production code, before any other change.
Scope note
Found while preparing the MetricEvent conversion of the H2 metric sites (#1341 Q4). That work
adds the first e2e test that reads this gauge, for the H2 path and for the shared decrement, and
that test is the gate on moving the metric at all — but repairing tests 15/16/17 is a separate
changeset with its own reds, and is deliberately not folded into it.
Activity
refactor(mux-h2): return the shared leaves' metrics as MetricEvents (#…
test(mux): read the gauge the three active_requests e2e tests are nam…