diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 7c14a775836..beaafe63ac1 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -121,6 +121,7 @@ https://github.com/elastic/beats/compare/v6.2.3...v6.3.0[View commits] - Ensure Kubernetes labels/annotations don't break mapping {pull}6490[6490] - Ensure that the dashboard zip files can't contain files outside of the kibana directory. {pull}6921[6921] - Fix map overwrite panics by cloning shared structs before doing the update. {pull}6947[6947] +- Fix delays on autodiscovery events handling caused by blocking runner stops. {pull}7170[7170] *Auditbeat* diff --git a/libbeat/autodiscover/autodiscover.go b/libbeat/autodiscover/autodiscover.go index cd7b557168d..945e524157a 100644 --- a/libbeat/autodiscover/autodiscover.go +++ b/libbeat/autodiscover/autodiscover.go @@ -174,8 +174,12 @@ func (a *Autodiscover) handleStop(event bus.Event) { } if runner := a.runners.Get(hash); runner != nil { + // Stop can block, we run it asyncrhonously to avoid blocking + // the whole events loop. The runner hash is removed in any case + // so an equivalent configuration can be added again while this + // one stops, and a duplicated event don't try to stop it twice. logp.Info("Autodiscover stopping runner: %s", runner) - runner.Stop() + go runner.Stop() a.runners.Remove(hash) } else { logp.Debug(debugK, "Runner not found for stopping: %s", hash)