Cherry-pick #23722 to 7.10: Fix leak caused by input runners created when checking their configuration #23805
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cherry-pick of PR #23722 to 7.10 branch. Original message:
What does this PR do?
Stop input v1 runners created to check config.
CheckConfig
for v1 inputs actually calls the constructors of the inputs. In some cases, as in thelog
input, the constructor creates resources that are never released unless the runner is stopped. This causes goroutines leaks with autodiscover or other dynamic configurations.As discovered in #23658, this started to cause leaks since 7.8.0 (specifically since #16715), but I am not sure why this was not an issue before as config checkers were moved there but not really changed. Perhaps before this change input configs were not actually checked.
Considered alternatives
Start()
Run()
doesn't return errors, and it may be too late to do some checks expected now in the builder.CheckConfig
. Not sure if this would be very different at the end, and we would need to rely on inputs releasing their resources if the context is done.CheckConfig
for inputs. A feature would be lost.Why is it important?
Avoid goroutines and other possible leaks with autodiscover in Filebeat.
Checklist
I have made corresponding changes to the documentationI have made corresponding change to the default configuration filesCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Author's Checklist
How to test this PR locally
-httpprof :6060
.curl http://localhost:6060/debug/pprof/goroutine -o /tmp/goroutines-base.prof
).go tool pprof -top -base /tmp/goroutines-base.prof http://localhost:6060/debug/pprof/goroutine
CloseOnSignal
orSubOutlets
.cleanup_timeout
) the started goroutines are not in pprof anymore.Related issues