@cryptotaxi247 / netdata-1 / commits / 0996abc7c

Check for chart obsoletion on children re-connections (#12707)

* check for chart obsoletion on children connections * use rrdset_is_obsolete

Emmanuel Vasilakis committed May 3, 2022 at 10:37 UTC 0996abc7c0ef80bf9d128cfe52b69082831c61e4
4 files changed +23 -1
database/rrd.h
+2
@@ -827,6 +827,8 @@ struct rrdhost {
827
828 struct receiver_state *receiver;
829 netdata_mutex_t receiver_lock;
830 + time_t trigger_chart_obsoletion_check; // set when child connects, will instruct parent to
831 + // trigger a check for obsoleted charts since previous connect
832
833 // ------------------------------------------------------------------------
834 // health monitoring options
database/rrdhost.c
+19
@@ -1528,6 +1528,16 @@ restart_after_removal:
1528 }
1529 }
1530
1531 +void rrdset_check_obsoletion(RRDHOST *host)
1532 +{
1533 + RRDSET *st;
1534 + rrdset_foreach_write(st, host) {
1535 + if (rrdset_last_entry_t(st) < host->trigger_chart_obsoletion_check) {
1536 + rrdset_is_obsolete(st);
1537 + }
1538 + }
1539 +}
1540 +
1541 void rrd_cleanup_obsolete_charts()
1542 {
1543 rrd_rdlock();
@@ -1547,6 +1557,15 @@ void rrd_cleanup_obsolete_charts()
1557 #endif
1558 rrdhost_unlock(host);
1559 }
1560 +
1561 + if (host != localhost &&
1562 + host->trigger_chart_obsoletion_check &&
1563 + host->trigger_chart_obsoletion_check + 120 < now_realtime_sec()) {
1564 + rrdhost_wrlock(host);
1565 + rrdset_check_obsoletion(host);
1566 + rrdhost_unlock(host);
1567 + host->trigger_chart_obsoletion_check = 0;
1568 + }
1569 }
1570
1571 rrd_unlock();
health/health.c
-1
@@ -808,7 +808,6 @@ void *health_main(void *ptr) {
808 #endif
809 }
810 }
811 - continue;
811 }
812
813 if (unlikely(!rrdcalc_isrunnable(rc, now, &next_run))) {
streaming/receiver.c
+2
@@ -646,6 +646,7 @@ static int rrdpush_receive(struct receiver_state *rpt)
646 rpt->host->hostname);
647 }
648 }
649 + rpt->host->trigger_chart_obsoletion_check = now_realtime_sec();
650 rrdhost_unlock(rpt->host);
651
652 // call the plugins.d processor to receive the metrics
@@ -686,6 +687,7 @@ static int rrdpush_receive(struct receiver_state *rpt)
687 if(health_enabled == CONFIG_BOOLEAN_AUTO)
688 rpt->host->health_enabled = 0;
689 }
690 + rpt->host->trigger_chart_obsoletion_check = 0;
691 rrdhost_unlock(rpt->host);
692 if (rpt->host->receiver == rpt) {
693 rrdpush_sender_thread_stop(rpt->host);