summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--database/rrd.h4
-rw-r--r--database/rrdhost.c11
-rw-r--r--database/rrdset.c4
-rw-r--r--streaming/receiver.c7
4 files changed, 19 insertions, 7 deletions
diff --git a/database/rrd.h b/database/rrd.h
index f8d9403cd9..dc32b2a2da 100644
--- a/database/rrd.h
+++ b/database/rrd.h
@@ -797,11 +797,13 @@ struct rrdhost {
volatile size_t connected_senders; // when remote hosts are streaming to this
// host, this is the counter of connected clients
+ time_t senders_connect_time; // the time the last sender was connected
+ time_t senders_last_chart_command; // the time of the last CHART streaming command
time_t senders_disconnected_time; // the time the last sender was disconnected
struct receiver_state *receiver;
netdata_mutex_t receiver_lock;
- time_t trigger_chart_obsoletion_check; // set when child connects, will instruct parent to
+ int trigger_chart_obsoletion_check; // set when child connects, will instruct parent to
// trigger a check for obsoleted charts since previous connect
// ------------------------------------------------------------------------
diff --git a/database/rrdhost.c b/database/rrdhost.c
index 4494fdf01f..cb56bf353a 100644
--- a/database/rrdhost.c
+++ b/database/rrdhost.c
@@ -1533,8 +1533,10 @@ 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) {
+ time_t last_entry_t;
+ rrdset_foreach_read(st, host) {
+ last_entry_t = rrdset_last_entry_t(st);
+ if (last_entry_t && last_entry_t < host->senders_connect_time) {
rrdset_is_obsolete(st);
}
}
@@ -1562,8 +1564,9 @@ void rrd_cleanup_obsolete_charts()
if (host != localhost &&
host->trigger_chart_obsoletion_check &&
- host->trigger_chart_obsoletion_check + 120 < now_realtime_sec()) {
- rrdhost_wrlock(host);
+ host->senders_last_chart_command &&
+ host->senders_last_chart_command + 120 < now_realtime_sec()) {
+ rrdhost_rdlock(host);
rrdset_check_obsoletion(host);
rrdhost_unlock(host);
host->trigger_chart_obsoletion_check = 0;
diff --git a/database/rrdset.c b/database/rrdset.c
index d7b9361a30..0dd84b4db1 100644
--- a/database/rrdset.c
+++ b/database/rrdset.c
@@ -552,6 +552,10 @@ RRDSET *rrdset_create_custom(
return NULL;
}
+ if (host != localhost) {
+ host->senders_last_chart_command = now_realtime_sec();
+ }
+
// ------------------------------------------------------------------------
// check if it already exists
diff --git a/streaming/receiver.c b/streaming/receiver.c
index 87f96039dc..4685f6bcd2 100644
--- a/streaming/receiver.c
+++ b/streaming/receiver.c
@@ -671,7 +671,9 @@ static int rrdpush_receive(struct receiver_state *rpt)
rpt->host->hostname);
}
}
- rpt->host->trigger_chart_obsoletion_check = now_realtime_sec();
+ rpt->host->senders_connect_time = now_realtime_sec();
+ rpt->host->senders_last_chart_command = 0;
+ rpt->host->trigger_chart_obsoletion_check = 1;
rrdhost_unlock(rpt->host);
// call the plugins.d processor to receive the metrics
@@ -707,12 +709,13 @@ static int rrdpush_receive(struct receiver_state *rpt)
rrdhost_wrlock(rpt->host);
netdata_mutex_lock(&rpt->host->receiver_lock);
if (rpt->host->receiver == rpt) {
+ rpt->host->senders_connect_time = 0;
+ rpt->host->trigger_chart_obsoletion_check = 0;
rpt->host->senders_disconnected_time = now_realtime_sec();
rrdhost_flag_set(rpt->host, RRDHOST_FLAG_ORPHAN);
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);