@cryptotaxi247 / netdata-1 / commits / e36fbebaa

Delete ML-related data of a host in the proper order. (#12672)

Initialization of ML-related structures and threads should happen when the underlying RRD objects have been fully initialized. Destruction should happen in the opposite way, ie. before deleting an RRD host/dimension.

vkalintiris committed Apr 12, 2022 at 17:40 UTC e36fbebaa205c1c3c2304a8395e74a118bcca17b
2 files changed +8 -3
database/rrdhost.c
+4 -2
@@ -848,6 +848,10 @@ void rrdhost_free(RRDHOST *host) {
848
849 rrd_check_wrlock(); // make sure the RRDs are write locked
850
851 + rrdhost_wrlock(host);
852 + ml_delete_host(host);
853 + rrdhost_unlock(host);
854 +
855 // ------------------------------------------------------------------------
856 // clean up streaming
857 rrdpush_sender_thread_stop(host); // stop a possibly running thread
@@ -937,8 +941,6 @@ void rrdhost_free(RRDHOST *host) {
941 rrdeng_exit(host->rrdeng_ctx);
942 #endif
943
940 - ml_delete_host(host);
941 -
944 // ------------------------------------------------------------------------
945 // remove it from the indexes
946
ml/ml.cc
+4 -1
@@ -90,7 +90,10 @@ void ml_delete_dimension(RRDDIM *RD) {
90 return;
91
92 Host *H = static_cast<Host *>(RD->rrdset->rrdhost->ml_host);
93 - H->removeDimension(D);
93 + if (!H)
94 + delete D;
95 + else
96 + H->removeDimension(D);
97
98 RD->state->ml_dimension = nullptr;
99 }