diff options
-rw-r--r-- | database/rrd.h | 2 | ||||
-rw-r--r-- | database/rrdhost.c | 19 | ||||
-rw-r--r-- | health/health.c | 1 | ||||
-rw-r--r-- | streaming/receiver.c | 2 |
4 files changed, 23 insertions, 1 deletions
diff --git a/database/rrd.h b/database/rrd.h index 4fa78b005a..371f1af6af 100644 --- a/database/rrd.h +++ b/database/rrd.h @@ -827,6 +827,8 @@ struct rrdhost { struct receiver_state *receiver; netdata_mutex_t receiver_lock; + time_t trigger_chart_obsoletion_check; // set when child connects, will instruct parent to + // trigger a check for obsoleted charts since previous connect // ------------------------------------------------------------------------ // health monitoring options diff --git a/database/rrdhost.c b/database/rrdhost.c index 649736ca4f..b0874e3d3d 100644 --- a/database/rrdhost.c +++ b/database/rrdhost.c @@ -1528,6 +1528,16 @@ restart_after_removal: } } +void rrdset_check_obsoletion(RRDHOST *host) +{ + RRDSET *st; + rrdset_foreach_write(st, host) { + if (rrdset_last_entry_t(st) < host->trigger_chart_obsoletion_check) { + rrdset_is_obsolete(st); + } + } +} + void rrd_cleanup_obsolete_charts() { rrd_rdlock(); @@ -1547,6 +1557,15 @@ void rrd_cleanup_obsolete_charts() #endif rrdhost_unlock(host); } + + if (host != localhost && + host->trigger_chart_obsoletion_check && + host->trigger_chart_obsoletion_check + 120 < now_realtime_sec()) { + rrdhost_wrlock(host); + rrdset_check_obsoletion(host); + rrdhost_unlock(host); + host->trigger_chart_obsoletion_check = 0; + } } rrd_unlock(); diff --git a/health/health.c b/health/health.c index e81c933303..912ddf6b26 100644 --- a/health/health.c +++ b/health/health.c @@ -808,7 +808,6 @@ void *health_main(void *ptr) { #endif } } - continue; } if (unlikely(!rrdcalc_isrunnable(rc, now, &next_run))) { diff --git a/streaming/receiver.c b/streaming/receiver.c index 1fcef26ff9..5cba2c9267 100644 --- a/streaming/receiver.c +++ b/streaming/receiver.c @@ -646,6 +646,7 @@ static int rrdpush_receive(struct receiver_state *rpt) rpt->host->hostname); } } + rpt->host->trigger_chart_obsoletion_check = now_realtime_sec(); rrdhost_unlock(rpt->host); // call the plugins.d processor to receive the metrics @@ -686,6 +687,7 @@ static int rrdpush_receive(struct receiver_state *rpt) if(health_enabled == CONFIG_BOOLEAN_AUTO) rpt->host->health_enabled = 0; } + rpt->host->trigger_chart_obsoletion_check = 0; rrdhost_unlock(rpt->host); if (rpt->host->receiver == rpt) { rrdpush_sender_thread_stop(rpt->host); |