Просмотр исходного кода

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 2 лет назад
Родитель
Сommit
e36fbebaa2
2 измененных файлов с 8 добавлено и 3 удалено
  1. 4 2
      database/rrdhost.c
  2. 4 1
      ml/ml.cc

+ 4 - 2
database/rrdhost.c

@@ -848,6 +848,10 @@ void rrdhost_free(RRDHOST *host) {
 
     rrd_check_wrlock();     // make sure the RRDs are write locked
 
+    rrdhost_wrlock(host);
+    ml_delete_host(host);
+    rrdhost_unlock(host);
+
     // ------------------------------------------------------------------------
     // clean up streaming
     rrdpush_sender_thread_stop(host); // stop a possibly running thread
@@ -937,8 +941,6 @@ void rrdhost_free(RRDHOST *host) {
         rrdeng_exit(host->rrdeng_ctx);
 #endif
 
-    ml_delete_host(host);
-
     // ------------------------------------------------------------------------
     // remove it from the indexes
 

+ 4 - 1
ml/ml.cc

@@ -90,7 +90,10 @@ void ml_delete_dimension(RRDDIM *RD) {
         return;
 
     Host *H = static_cast<Host *>(RD->rrdset->rrdhost->ml_host);
-    H->removeDimension(D);
+    if (!H)
+        delete D;
+    else
+        H->removeDimension(D);
 
     RD->state->ml_dimension = nullptr;
 }