This is an automated email from the ASF dual-hosted git repository.

moonchen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new f92e5bf680 rate_limit: don't update metrics when a selector has no 
`metrics:` block (#13343)
f92e5bf680 is described below

commit f92e5bf680969ea6a3592d446a6bcc452617e431
Author: Mo Chen <[email protected]>
AuthorDate: Mon Jul 6 17:25:24 2026 -0500

    rate_limit: don't update metrics when a selector has no `metrics:` block 
(#13343)
    
    A selector configured without a `metrics:` block should be a metrics no-op.
    It isn't: _metrics is value-initialized to 0, but incrementMetric() only
    suppresses the update when an entry equals the TS_ERROR (-1) sentinel that
    metric_helper() uses for "not registered". So the guard never fires and 
every
    queue/reject/expire/resume calls TSStatIntIncrement() on an unregistered ID.
    (It currently lands on the reserved bad_id slot, so it is absorbed rather 
than
    fatal -- but the plugin still should not emit anything.)
    
    Default _metrics to TS_ERROR in the constructor so incrementMetric() stays a
    no-op until metrics are actually registered.
---
 plugins/experimental/rate_limit/limiter.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/experimental/rate_limit/limiter.h 
b/plugins/experimental/rate_limit/limiter.h
index 2e40d5e140..6696274faf 100644
--- a/plugins/experimental/rate_limit/limiter.h
+++ b/plugins/experimental/rate_limit/limiter.h
@@ -180,7 +180,7 @@ template <class T> class RateLimiter
   using self_type = RateLimiter;
 
 public:
-  RateLimiter()                           = default;
+  RateLimiter() { _metrics.fill(TS_ERROR); }
   RateLimiter(self_type &&)               = delete;
   self_type &operator=(const self_type &) = delete;
   self_type &operator=(self_type &&)      = delete;

Reply via email to