@cryptotaxi247 / netdata-1 / commits / fc52535a1

Fix crash on child reconnect and lost metrics (#13821)

Increase page_index reference count on metric_get Don't free the db_metric_handle

Stelios Fragkakis committed Oct 14, 2022 at 07:52 UTC fc52535a16cc25be155747f644ff5268492f459d
1 file changed +1 -2
database/engine/rrdengineapi.c
+1 -2
@@ -124,8 +124,6 @@ void rrdeng_metric_release(STORAGE_METRIC_HANDLE *db_metric_handle) {
124 page_index->alignment = NULL;
125 }
126 uv_rwlock_rdunlock(&pg_cache->metrics_index.lock);
127 -
128 - freez(db_metric_handle);
127 }
128
129 STORAGE_METRIC_HANDLE *rrdeng_metric_get(STORAGE_INSTANCE *db_instance, uuid_t *uuid, STORAGE_METRICS_GROUP *smg) {
@@ -170,6 +168,7 @@ STORAGE_METRIC_HANDLE *rrdeng_metric_create(STORAGE_INSTANCE *db_instance, uuid_
168 page_index->prev = pg_cache->metrics_index.last_page_index;
169 pg_cache->metrics_index.last_page_index = page_index;
170 page_index->alignment = pa;
171 + page_index->refcount = 1;
172 if(pa)
173 pa->refcount++;
174 uv_rwlock_wrunlock(&pg_cache->metrics_index.lock);