@cryptotaxi247 / netdata-1 / commits / b8254f949

Metric release does not need to fetch retention (#17033)

metric release does not need to fetch retention

Stelios Fragkakis committed Feb 19, 2024 at 17:52 UTC b8254f9495fee8ab38a949b0ee216f74dbc3c83f
2 files changed +8 -4
src/database/engine/metric.c
+7 -3
@@ -153,7 +153,7 @@ static inline REFCOUNT metric_acquire(MRG *mrg __maybe_unused, METRIC *metric) {
153 return refcount;
154 }
155
156 -static inline bool metric_release_and_can_be_deleted(MRG *mrg __maybe_unused, METRIC *metric) {
156 +static inline void metric_release(MRG *mrg __maybe_unused, METRIC *metric) {
157 spinlock_lock(&metric->refcount_spinlock);
158
159 if (metric->refcount <= 0)
@@ -169,6 +169,10 @@ static inline bool metric_release_and_can_be_deleted(MRG *mrg __maybe_unused, ME
169 __atomic_sub_fetch(&mrg->index[partition].stats.entries_referenced, 1, __ATOMIC_RELAXED);
170
171 __atomic_sub_fetch(&mrg->index[partition].stats.current_references, 1, __ATOMIC_RELAXED);
172 +}
173 +
174 +static inline bool metric_release_and_can_be_deleted(MRG *mrg __maybe_unused, METRIC *metric) {
175 + metric_release(mrg, metric);
176
177 time_t first, last;
178 mrg_metric_get_retention(mrg, metric, &first, &last, NULL);
@@ -376,8 +380,8 @@ inline METRIC *mrg_metric_dup(MRG *mrg, METRIC *metric) {
380 return metric;
381 }
382
379 -inline bool mrg_metric_release(MRG *mrg, METRIC *metric) {
380 - return metric_release_and_can_be_deleted(mrg, metric);
383 +inline void mrg_metric_release(MRG *mrg, METRIC *metric) {
384 + metric_release(mrg, metric);
385 }
386
387 inline Word_t mrg_metric_id(MRG *mrg __maybe_unused, METRIC *metric) {
src/database/engine/metric.h
+1 -1
@@ -52,7 +52,7 @@ MRG *mrg_create(ssize_t partitions);
52 void mrg_destroy(MRG *mrg);
53
54 METRIC *mrg_metric_dup(MRG *mrg, METRIC *metric);
55 -bool mrg_metric_release(MRG *mrg, METRIC *metric);
55 +void mrg_metric_release(MRG *mrg, METRIC *metric);
56
57 METRIC *mrg_metric_add_and_acquire(MRG *mrg, MRG_ENTRY entry, bool *ret);
58 METRIC *mrg_metric_get_and_acquire(MRG *mrg, uuid_t *uuid, Word_t section);