You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ma...@apache.org on 2026/10/21 23:50:45 UTC
(trafficserver) branch master updated: Fix per-volume direntries.used undercount at startup (#13841)
This is an automated email from the ASF dual-hosted git repository.
masaori335 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 2ac2edcaea Fix per-volume direntries.used undercount at startup (#13841)
2ac2edcaea is described below
commit 2ac2edcaeab6bcfe2f1ba093b3e2b75820f3e739
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Thu Oct 22 08:50:38 2026 +0900
Fix per-volume direntries.used undercount at startup (#13841)
Directory recovery runs before cacheInitialized() seeds the gauges, so
its decrements land on an unseeded gauge. The global gauge is stored and
recovers, but the per-volume gauge was incremented on top of the
decrements and stayed low, wrapping to ~2^64 when recovery cleared most
of a stripe. Zero the per-volume gauges before summing, and drop the
decrements in clear_range(), which only runs during recovery.
---
src/iocore/cache/CacheDir.cc | 7 ++++---
src/iocore/cache/CacheProcessor.cc | 5 +++++
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/iocore/cache/CacheDir.cc b/src/iocore/cache/CacheDir.cc
index d78b197ad6..c1cfad527e 100644
--- a/src/iocore/cache/CacheDir.cc
+++ b/src/iocore/cache/CacheDir.cc
@@ -375,15 +375,16 @@ Directory::cleanup(StripeSM *stripe)
CHECK_DIR(d);
}
+/**
+ Recovery only: cacheInitialized() stores the gauges afterwards, so debiting them here would be overwritten.
+ */
void
Directory::clear_range(off_t start, off_t end, StripeSM *stripe)
{
for (off_t i = 0; i < this->entries(); i++) {
Dir *e = dir_index(stripe, i);
if (dir_offset(e) >= static_cast<int64_t>(start) && dir_offset(e) < static_cast<int64_t>(end)) {
- ts::Metrics::Gauge::decrement(cache_rsb.direntries_used);
- ts::Metrics::Gauge::decrement(stripe->cache_vol->vol_rsb.direntries_used);
- dir_set_offset(e, 0); // delete
+ dir_set_offset(e, 0);
}
}
this->cleanup(stripe);
diff --git a/src/iocore/cache/CacheProcessor.cc b/src/iocore/cache/CacheProcessor.cc
index 0e159481c9..e5a9c9ee43 100644
--- a/src/iocore/cache/CacheProcessor.cc
+++ b/src/iocore/cache/CacheProcessor.cc
@@ -1608,6 +1608,11 @@ CacheProcessor::cacheInitialized()
Dbg(dbg_ctl_cache_init, "Shared cache size (for RAM pool distribution): %" PRId64 " blocks", shared_cache_size);
}
+ // Recovery already debited the volume gauges; zero them before summing, as CachePeriodicMetricsUpdate() does.
+ for (int i = 0; i < gnstripes; i++) {
+ ts::Metrics::Gauge::store(gstripes[i]->cache_vol->vol_rsb.direntries_used, 0);
+ }
+
for (int i = 0; i < gnstripes; i++) {
StripeSM *stripe = gstripes[i];
int64_t ram_cache_bytes = 0;