diff options
author | Markos Fountoulakis <44345837+mfundul@users.noreply.github.com> | 2020-09-01 11:32:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-01 11:32:00 +0300 |
commit | d521566bc264788413a8d176d4c75045c873f0a8 (patch) | |
tree | 71f49a89e8e682131f7b3cf1df8f1307ce28bf08 /database | |
parent | f2e4a9ac510df53289922b4ed1fca0c352c51791 (diff) |
Fix multi-host DB corruption when legacy metrics reside in localhost. (#9855)
Diffstat (limited to 'database')
-rwxr-xr-x | database/engine/rrdengineapi.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/database/engine/rrdengineapi.c b/database/engine/rrdengineapi.c index 39647be73b..8a78e4bb9a 100755 --- a/database/engine/rrdengineapi.c +++ b/database/engine/rrdengineapi.c @@ -56,7 +56,8 @@ void rrdeng_metric_init(RRDDIM *rd, uuid_t *dim_uuid) uuid_t legacy_uuid; Pvoid_t *PValue; struct pg_cache_page_index *page_index = NULL; - int replace_instead_of_generate = 0; + int replace_instead_of_generate = 0, is_multihost_child = 0; + RRDHOST *host = rd->rrdset->rrdhost; ctx = get_rrdeng_ctx_from_host(rd->rrdset->rrdhost); if (unlikely(!ctx)) { @@ -67,6 +68,8 @@ void rrdeng_metric_init(RRDDIM *rd, uuid_t *dim_uuid) rrdeng_generate_legacy_uuid(rd->id, rd->rrdset->id, &legacy_uuid); rd->state->metric_uuid = callocz(1, sizeof(uuid_t)); + if (host != localhost && host->rrdeng_ctx == &multidb_ctx) + is_multihost_child = 1; uv_rwlock_rdlock(&pg_cache->metrics_index.lock); PValue = JudyHSGet(pg_cache->metrics_index.JudyHS_array, &legacy_uuid, sizeof(uuid_t)); @@ -74,8 +77,9 @@ void rrdeng_metric_init(RRDDIM *rd, uuid_t *dim_uuid) page_index = *PValue; } uv_rwlock_rdunlock(&pg_cache->metrics_index.lock); - if (NULL == PValue) { - /* First time we see the legacy UUID, drop legacy support, normal path */ + if (is_multihost_child || NULL == PValue) { + /* First time we see the legacy UUID or metric belongs to child host in multi-host DB. + * Drop legacy support, normal path */ if (NULL != dim_uuid) { replace_instead_of_generate = 1; |