From 9cb1704d3c30e9fa0c0f4a18a78a478df8bd8945 Mon Sep 17 00:00:00 2001 From: Hui Wang Date: Thu, 5 Sep 2024 22:42:49 +0800 Subject: [PATCH] lib/storage: fix metric `vm_object_references{type="indexdb"}` (#6937) follow up https://github.com/VictoriaMetrics/VictoriaMetrics/commit/4ecc370acb541447739e4c2c72e2d7179a650bd9 ### Describe Your Changes Please provide a brief description of the changes you made. Be as specific as possible to help others understand the purpose and impact of your modifications. ### Checklist The following checks are **mandatory**: - [ ] My change adheres [VictoriaMetrics contributing guidelines](https://docs.victoriametrics.com/contributing/). --- docs/changelog/CHANGELOG.md | 1 + lib/storage/index_db.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/changelog/CHANGELOG.md b/docs/changelog/CHANGELOG.md index 8d92d99e50..1cdb765805 100644 --- a/docs/changelog/CHANGELOG.md +++ b/docs/changelog/CHANGELOG.md @@ -25,6 +25,7 @@ See also [LTS releases](https://docs.victoriametrics.com/lts-releases/). * BUGFIX: [vmagent dashboard](https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/dashboards/vmagent.json): fix legend captions for stream aggregation related panels. Before they were displaying wrong label names. * BUGFIX: [vmgateway](https://docs.victoriametrics.com/vmgateway/): add missing `datadog`, `newrelic`, `opentelemetry` and `pushgateway` routes to the `JWT` authorization routes. Allows prefixed (`promtheus/graphite`) routes for query requests. +* BUGFIX: [Single-node VictoriaMetrics](https://docs.victoriametrics.com/) and `vmstorage` in [VictoriaMetrics cluster](https://docs.victoriametrics.com/cluster-victoriametrics/): fix metric `vm_object_references{type="indexdb"}`. Previously, it was overcounted. ## [v1.103.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.103.0) diff --git a/lib/storage/index_db.go b/lib/storage/index_db.go index 19e6fe42ba..1606d5dd83 100644 --- a/lib/storage/index_db.go +++ b/lib/storage/index_db.go @@ -224,6 +224,9 @@ func (db *indexDB) UpdateMetrics(m *IndexDBMetrics) { m.TagFiltersToMetricIDsCacheMisses += cs.Misses m.IndexDBRefCount += uint64(db.refCount.Load()) + + // this shouldn't increase the MissingTSIDsForMetricID value, + // as we only count it as missingTSIDs if it can't be found in both the current and previous indexdb. m.MissingTSIDsForMetricID += db.missingTSIDsForMetricID.Load() m.DateRangeSearchCalls += db.dateRangeSearchCalls.Load() @@ -252,7 +255,6 @@ func (db *indexDB) UpdateMetrics(m *IndexDBMetrics) { m.GlobalSearchCalls += extDB.globalSearchCalls.Load() m.MissingMetricNamesForMetricID += extDB.missingMetricNamesForMetricID.Load() - m.IndexDBRefCount += uint64(extDB.refCount.Load()) }) }