diff options
author | Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com> | 2021-06-01 14:26:22 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-01 14:26:22 +0300 |
commit | 37bee1d197229a4de1d6eac9942fc626f1da8ee3 (patch) | |
tree | f975420d4f6cd6c47dbd5c8735a71e649041a281 /database/engine/rrdengineapi.c | |
parent | 0d96e0a187ee3419a9939b56970248356d05c1e7 (diff) |
Store uuid_t metric_uuid in the dimension state structure instead of uuid_t * (#11212)
Diffstat (limited to 'database/engine/rrdengineapi.c')
-rwxr-xr-x | database/engine/rrdengineapi.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/database/engine/rrdengineapi.c b/database/engine/rrdengineapi.c index d847969e85..d81b95805b 100755 --- a/database/engine/rrdengineapi.c +++ b/database/engine/rrdengineapi.c @@ -49,7 +49,7 @@ void rrdeng_convert_legacy_uuid_to_multihost(char machine_guid[GUID_LEN + 1], uu memcpy(ret_uuid, hash_value, sizeof(uuid_t)); } -void rrdeng_metric_init(RRDDIM *rd, uuid_t *dim_uuid) +void rrdeng_metric_init(RRDDIM *rd) { struct page_cache *pg_cache; struct rrdengine_instance *ctx; @@ -68,7 +68,6 @@ void rrdeng_metric_init(RRDDIM *rd, uuid_t *dim_uuid) pg_cache = &ctx->pg_cache; rrdeng_generate_legacy_uuid(rd->id, rd->rrdset->id, &legacy_uuid); - rd->state->metric_uuid = dim_uuid; if (host != localhost && host->rrdeng_ctx == &multidb_ctx) is_multihost_child = 1; @@ -82,20 +81,17 @@ void rrdeng_metric_init(RRDDIM *rd, uuid_t *dim_uuid) /* First time we see the legacy UUID or metric belongs to child host in multi-host DB. * Drop legacy support, normal path */ - if (unlikely(!rd->state->metric_uuid)) - rd->state->metric_uuid = create_dimension_uuid(rd->rrdset, rd); - uv_rwlock_rdlock(&pg_cache->metrics_index.lock); - PValue = JudyHSGet(pg_cache->metrics_index.JudyHS_array, rd->state->metric_uuid, sizeof(uuid_t)); + PValue = JudyHSGet(pg_cache->metrics_index.JudyHS_array, &rd->state->metric_uuid, sizeof(uuid_t)); if (likely(NULL != PValue)) { page_index = *PValue; } uv_rwlock_rdunlock(&pg_cache->metrics_index.lock); if (NULL == PValue) { uv_rwlock_wrlock(&pg_cache->metrics_index.lock); - PValue = JudyHSIns(&pg_cache->metrics_index.JudyHS_array, rd->state->metric_uuid, sizeof(uuid_t), PJE0); + PValue = JudyHSIns(&pg_cache->metrics_index.JudyHS_array, &rd->state->metric_uuid, sizeof(uuid_t), PJE0); fatal_assert(NULL == *PValue); /* TODO: figure out concurrency model */ - *PValue = page_index = create_page_index(rd->state->metric_uuid); + *PValue = page_index = create_page_index(&rd->state->metric_uuid); page_index->prev = pg_cache->metrics_index.last_page_index; pg_cache->metrics_index.last_page_index = page_index; uv_rwlock_wrunlock(&pg_cache->metrics_index.lock); @@ -106,15 +102,12 @@ void rrdeng_metric_init(RRDDIM *rd, uuid_t *dim_uuid) rrdeng_convert_legacy_uuid_to_multihost(rd->rrdset->rrdhost->machine_guid, &legacy_uuid, &multihost_legacy_uuid); - if (unlikely(!rd->state->metric_uuid)) - rd->state->metric_uuid = mallocz(sizeof(uuid_t)); - - int need_to_store = (dim_uuid == NULL || uuid_compare(*rd->state->metric_uuid, multihost_legacy_uuid)); + int need_to_store = uuid_compare(rd->state->metric_uuid, multihost_legacy_uuid); - uuid_copy(*rd->state->metric_uuid, multihost_legacy_uuid); + uuid_copy(rd->state->metric_uuid, multihost_legacy_uuid); if (unlikely(need_to_store)) - (void)sql_store_dimension(rd->state->metric_uuid, rd->rrdset->chart_uuid, rd->id, rd->name, rd->multiplier, rd->divisor, + (void)sql_store_dimension(&rd->state->metric_uuid, rd->rrdset->chart_uuid, rd->id, rd->name, rd->multiplier, rd->divisor, rd->algorithm); } |