Skip to content

StatsAccessLogger: fixes connection gauge underflow crashes when decrementing metrics after Scope evictions.#43812

Merged
ggreenway merged 78 commits into
envoyproxy:mainfrom
TAOXUY:fixStatDestructor
Apr 6, 2026
Merged

StatsAccessLogger: fixes connection gauge underflow crashes when decrementing metrics after Scope evictions.#43812
ggreenway merged 78 commits into
envoyproxy:mainfrom
TAOXUY:fixStatDestructor

Remove log line check in integration test

babe799
Select commit
Loading
Failed to load commit list.
CI (Envoy) / Envoy/Publish and verify succeeded Apr 6, 2026 in 1h 3m 36s

Envoy/Publish and verify (success)

Check has finished

Details

Check run finished (success ✔️)

The check run can be viewed here:

Envoy/Publish and verify (pr/43812/main@babe799)

Check started by

Request (pr/43812/main@babe799)

TAOXUY @TAOXUY babe799 #43812 merge main@3424968

StatsAccessLogger: fixes connection gauge underflow crashes when decrementing metrics after Scope evictions.

Description: Fixes connection gauge underflow crashes in the Stats Access Logger when decrementing metrics after Scope evictions.

The original code correctly attempted to prevent "zombie" gauges by re-resolving metrics against the central store (via scope_->gaugeFromStatNameWithTags) during request destruction. However, it tried to reconstruct the gauge's identity using gauge_->tagExtractedStatName(). This failed because dynamic access-log tags (like %REQUEST_HEADER(...)%) are not registered with Envoy's global extractors. The extraction process returned a mangled base name and empty tags, forcing Scope to create a new 0-valued gauge. Subtracting 1 from it immediately crashed Envoy with a counter underflow.

Fix: we will keep the gauge in the scope cache if it is non-zero

Risk Level: Low

Testing: Added StatsAccessLogIntegrationTest.ActiveRequestsGaugeScopeEviction, which synthetically forces an asynchronous scope eviction while a connection is still inflight. Verified that the gauge successfully decrements to 0 in the central store identically to a normal request finish.

Docs: NA

Release: NA

Platform Specific Features: no

Environment

Request variables

Key Value
ref 9d7ec4d
sha babe799
pr 43812
base-sha 3424968
actor TAOXUY @TAOXUY
message StatsAccessLogger: fixes connection gauge underflow crashes when decrementing metrics after Scope evictions....
started 1775489694.88637
target-branch main
trusted false
Build image

Container image/s (as used in this CI run)

Key Value
default docker.io/envoyproxy/envoy-build:86873047235e9b8232df989a5999b9bebf9db69c
mobile docker.io/envoyproxy/envoy-build:mobile-86873047235e9b8232df989a5999b9bebf9db69c
Version

Envoy version (as used in this CI run)

Key Value
major 1
minor 38
patch 0
dev true