From adf253f710f62106193bbcf5f46543ba6fd93d2a Mon Sep 17 00:00:00 2001 From: Markos Fountoulakis <44345837+mfundul@users.noreply.github.com> Date: Fri, 4 Sep 2020 13:03:25 +0300 Subject: Fix race condition with orphan hosts (#9862) * Fix race condition between orphan host cleanup and new streaming connections. * Remove health enabling from log replay, it will be handled at streaming connection time. --- database/engine/metadata_log/metalogpluginsd.c | 6 +----- database/rrdhost.c | 6 ++++++ 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'database') diff --git a/database/engine/metadata_log/metalogpluginsd.c b/database/engine/metadata_log/metalogpluginsd.c index 25af24143b..1fa94e315a 100755 --- a/database/engine/metadata_log/metalogpluginsd.c +++ b/database/engine/metadata_log/metalogpluginsd.c @@ -12,7 +12,6 @@ PARSER_RC metalog_pluginsd_host_action( { int history = 5; RRD_MEMORY_MODE mode = RRD_MEMORY_MODE_DBENGINE; - int health_enabled = default_health_enabled; int rrdpush_enabled = default_rrdpush_enabled; char *rrdpush_destination = default_rrdpush_destination; char *rrdpush_api_key = default_rrdpush_api_key; @@ -49,9 +48,6 @@ PARSER_RC metalog_pluginsd_host_action( update_every = (int)appconfig_get_number(&stream_config, machine_guid, "update every", update_every); if(update_every < 0) update_every = 1; - //health_enabled = appconfig_get_boolean_ondemand(&stream_config, rpt->key, "health enabled by default", health_enabled); - health_enabled = appconfig_get_boolean_ondemand(&stream_config, machine_guid, "health enabled", health_enabled); - //rrdpush_enabled = appconfig_get_boolean(&stream_config, rpt->key, "default proxy enabled", rrdpush_enabled); rrdpush_enabled = appconfig_get_boolean(&stream_config, machine_guid, "proxy enabled", rrdpush_enabled); @@ -77,7 +73,7 @@ PARSER_RC metalog_pluginsd_host_action( , update_every , history // entries , mode - , health_enabled // health enabled + , 0 // health enabled , rrdpush_enabled // Push enabled , rrdpush_destination //destination , rrdpush_api_key // api key diff --git a/database/rrdhost.c b/database/rrdhost.c index 08bdb1b3ba..c5e0e069cd 100644 --- a/database/rrdhost.c +++ b/database/rrdhost.c @@ -573,6 +573,12 @@ RRDHOST *rrdhost_find_or_create( , rrdpush_send_charts_matching , system_info); } + if (host) { + rrdhost_wrlock(host); + rrdhost_flag_clear(host, RRDHOST_FLAG_ORPHAN); + host->senders_disconnected_time = 0; + rrdhost_unlock(host); + } rrdhost_cleanup_orphan_hosts_nolock(host); -- cgit v1.2.3