diff options
author | Vladimir Kobal <vlad@prokk.net> | 2020-05-14 11:42:40 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-14 11:42:40 +0300 |
commit | a606a27f164b1c704d850c838a7b89d6c6e0c17c (patch) | |
tree | 1d653e680fa8b6f9c1a6653d87ac6faef60c71f9 /exporting/process_data.c | |
parent | bb61e46e71777b467513a2b102fccdc5f5a8cd0b (diff) |
Fix error handling in exporting connector (#8910)
Diffstat (limited to 'exporting/process_data.c')
-rw-r--r-- | exporting/process_data.c | 100 |
1 files changed, 28 insertions, 72 deletions
diff --git a/exporting/process_data.c b/exporting/process_data.c index f2442e701c..b3d0fdef2d 100644 --- a/exporting/process_data.c +++ b/exporting/process_data.c @@ -43,7 +43,7 @@ int mark_scheduled_instances(struct engine *engine) int instances_were_scheduled = 0; for (struct instance *instance = engine->instance_root; instance; instance = instance->next) { - if (engine->now % instance->config.update_every < localhost->rrd_update_every) { + if (!instance->disabled && (engine->now % instance->config.update_every < localhost->rrd_update_every)) { instance->scheduled = 1; instances_were_scheduled = 1; instance->before = engine->now; @@ -160,21 +160,18 @@ calculated_number exporting_calculate_value_from_stored_data( * Start batch formatting for every connector instance's buffer * * @param engine an engine data structure. - * @return Returns 0 on success, 1 on failure. */ -int start_batch_formatting(struct engine *engine) +void start_batch_formatting(struct engine *engine) { for (struct instance *instance = engine->instance_root; instance; instance = instance->next) { if (instance->scheduled) { uv_mutex_lock(&instance->mutex); if (instance->start_batch_formatting && instance->start_batch_formatting(instance) != 0) { error("EXPORTING: cannot start batch formatting for %s", instance->config.name); - return 1; + disable_instance(instance); } } } - - return 0; } /** @@ -182,24 +179,21 @@ int start_batch_formatting(struct engine *engine) * * @param engine an engine data structure. * @param host a data collecting host. - * @return Returns 0 on success, 1 on failure. */ -int start_host_formatting(struct engine *engine, RRDHOST *host) +void start_host_formatting(struct engine *engine, RRDHOST *host) { for (struct instance *instance = engine->instance_root; instance; instance = instance->next) { if (instance->scheduled) { if (rrdhost_is_exportable(instance, host)) { if (instance->start_host_formatting && instance->start_host_formatting(instance, host) != 0) { error("EXPORTING: cannot start host formatting for %s", instance->config.name); - return 1; + disable_instance(instance); } } else { instance->skip_host = 1; } } } - - return 0; } /** @@ -207,24 +201,21 @@ int start_host_formatting(struct engine *engine, RRDHOST *host) * * @param engine an engine data structure. * @param st a chart. - * @return Returns 0 on success, 1 on failure. */ -int start_chart_formatting(struct engine *engine, RRDSET *st) +void start_chart_formatting(struct engine *engine, RRDSET *st) { for (struct instance *instance = engine->instance_root; instance; instance = instance->next) { if (instance->scheduled && !instance->skip_host) { if (rrdset_is_exportable(instance, st)) { if (instance->start_chart_formatting && instance->start_chart_formatting(instance, st) != 0) { error("EXPORTING: cannot start chart formatting for %s", instance->config.name); - return 1; + disable_instance(instance); } } else { instance->skip_chart = 1; } } } - - return 0; } /** @@ -232,21 +223,19 @@ int start_chart_formatting(struct engine *engine, RRDSET *st) * * @param engine an engine data structure. * @param rd a dimension(metric) in the Netdata database. - * @return Returns 0 on success, 1 on failure. */ -int metric_formatting(struct engine *engine, RRDDIM *rd) +void metric_formatting(struct engine *engine, RRDDIM *rd) { for (struct instance *instance = engine->instance_root; instance; instance = instance->next) { if (instance->scheduled && !instance->skip_host && !instance->skip_chart) { if (instance->metric_formatting && instance->metric_formatting(instance, rd) != 0) { error("EXPORTING: cannot format metric for %s", instance->config.name); - return 1; + disable_instance(instance); + continue; } instance->stats.buffered_metrics++; } } - - return 0; } /** @@ -254,21 +243,19 @@ int metric_formatting(struct engine *engine, RRDDIM *rd) * * @param engine an engine data structure. * @param a chart. - * @return Returns 0 on success, 1 on failure. */ -int end_chart_formatting(struct engine *engine, RRDSET *st) +void end_chart_formatting(struct engine *engine, RRDSET *st) { for (struct instance *instance = engine->instance_root; instance; instance = instance->next) { if (instance->scheduled && !instance->skip_host && !instance->skip_chart) { if (instance->end_chart_formatting && instance->end_chart_formatting(instance, st) != 0) { error("EXPORTING: cannot end chart formatting for %s", instance->config.name); - return 1; + disable_instance(instance); + continue; } } instance->skip_chart = 0; } - - return 0; } /** @@ -276,36 +263,34 @@ int end_chart_formatting(struct engine *engine, RRDSET *st) * * @param engine an engine data structure. * @param host a data collecting host. - * @return Returns 0 on success, 1 on failure. */ -int end_host_formatting(struct engine *engine, RRDHOST *host) +void end_host_formatting(struct engine *engine, RRDHOST *host) { for (struct instance *instance = engine->instance_root; instance; instance = instance->next) { if (instance->scheduled && !instance->skip_host) { if (instance->end_host_formatting && instance->end_host_formatting(instance, host) != 0) { error("EXPORTING: cannot end host formatting for %s", instance->config.name); - return 1; + disable_instance(instance); + continue; } } instance->skip_host = 0; } - - return 0; } /** * End batch formatting for every connector instance's buffer * * @param engine an engine data structure. - * @return Returns 0 on success, 1 on failure. */ -int end_batch_formatting(struct engine *engine) +void end_batch_formatting(struct engine *engine) { for (struct instance *instance = engine->instance_root; instance; instance = instance->next) { if (instance->scheduled) { if (instance->end_batch_formatting && instance->end_batch_formatting(instance) != 0) { error("EXPORTING: cannot end batch formatting for %s", instance->config.name); - return 1; + disable_instance(instance); + continue; } uv_mutex_unlock(&instance->mutex); uv_cond_signal(&instance->cond_var); @@ -314,8 +299,6 @@ int end_batch_formatting(struct engine *engine) instance->after = instance->before; } } - - return 0; } /** @@ -325,51 +308,39 @@ int end_batch_formatting(struct engine *engine) * configured rules. * * @param engine an engine data structure. - * @return Returns 0 on success, 1 on failure. */ -int prepare_buffers(struct engine *engine) +void prepare_buffers(struct engine *engine) { - if (start_batch_formatting(engine) != 0) - return 1; - netdata_thread_disable_cancelability(); + start_batch_formatting(engine); + rrd_rdlock(); RRDHOST *host; rrdhost_foreach_read(host) { rrdhost_rdlock(host); - if (start_host_formatting(engine, host) != 0) - return 1; + start_host_formatting(engine, host); RRDSET *st; rrdset_foreach_read(st, host) { rrdset_rdlock(st); - if (start_chart_formatting(engine, st) != 0) - return 1; + start_chart_formatting(engine, st); RRDDIM *rd; rrddim_foreach_read(rd, st) - { - if (metric_formatting(engine, rd) != 0) - return 1; - } + metric_formatting(engine, rd); - if (end_chart_formatting(engine, st) != 0) - return 1; + end_chart_formatting(engine, st); rrdset_unlock(st); } - if (end_host_formatting(engine, host) != 0) - return 1; + end_host_formatting(engine, host); rrdhost_unlock(host); } rrd_unlock(); netdata_thread_enable_cancelability(); - if (end_batch_formatting(engine) != 0) - return 1; - - return 0; + end_batch_formatting(engine); } /** @@ -401,18 +372,3 @@ int simple_connector_update_buffered_bytes(struct instance *instance) return 0; } - -/** - * Notify workers - * - * Notify exporting connector instance working threads that data is ready to send. - * - * @param engine an engine data structure. - * @return Returns 0 on success, 1 on failure. - */ -int notify_workers(struct engine *engine) -{ - (void)engine; - - return 0; -} |