Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(telegrafreceiver): make shutdown safe to call before start #913

Merged
merged 1 commit into from
Jan 30, 2023

Conversation

swiatekm
Copy link

Shutdown can be called without Start having been called before. In particular, this happens if there's an error starting a component in the pipeline before receivers are started. We then get a segfault:

2023-01-30T12:49:29.788+0100    info    service/pipelines.go:121        Stopping receivers...
2023-01-30T12:49:29.788+0100    info    telegrafreceiver/receiver.go:156        Stopping telegraf receiver      {"kind": "receiver", "name": "telegraf", "pipeline": "metrics"}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x2f7cd0f]

goroutine 1 [running]:
github.com/SumoLogic/sumologic-otel-collector/pkg/receiver/telegrafreceiver.(*telegrafreceiver).Shutdown.func1()
        github.com/SumoLogic/sumologic-otel-collector/pkg/receiver/telegrafreceiver/receiver.go:157 +0x4f
sync.(*Once).doSlow(0xc9057e?, 0x7000000087044ad?)
        sync/once.go:74 +0xc2
sync.(*Once).Do(...)
        sync/once.go:65
github.com/SumoLogic/sumologic-otel-collector/pkg/receiver/telegrafreceiver.(*telegrafreceiver).Shutdown(0x7f00e0?, {0x62e7db5?, 0x2?})
        github.com/SumoLogic/sumologic-otel-collector/pkg/receiver/telegrafreceiver/receiver.go:155 +0xd5
go.opentelemetry.io/collector/service.(*builtPipelines).ShutdownAll(0xc001565400, {0x6f71400, 0xc000194000})
        go.opentelemetry.io/[email protected]/service/pipelines.go:124 +0x499
go.opentelemetry.io/collector/service.(*Service).Shutdown(0xc000925680, {0x6f71400, 0xc000194000})
        go.opentelemetry.io/[email protected]/service/service.go:155 +0xd4
go.opentelemetry.io/collector/otelcol.(*Collector).setupConfigurationComponents(0xc0014bfaa8, {0x6f71400, 0xc000194000})
        go.opentelemetry.io/[email protected]/otelcol/collector.go:181 +0x568
go.opentelemetry.io/collector/otelcol.(*Collector).Run(0xc0014bfaa8, {0x6f71400, 0xc000194000})
        go.opentelemetry.io/[email protected]/otelcol/collector.go:205 +0x65
go.opentelemetry.io/collector/otelcol.NewCommand.func1(0xc0001fc000, {0x6296a87?, 0x1?, 0x1?})
        go.opentelemetry.io/[email protected]/otelcol/command.go:53 +0x419
github.com/spf13/cobra.(*Command).execute(0xc0001fc000, {0xc0001a2010, 0x1, 0x1})
        github.com/spf13/[email protected]/command.go:916 +0x862
github.com/spf13/cobra.(*Command).ExecuteC(0xc0001fc000)
        github.com/spf13/[email protected]/command.go:1044 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/[email protected]/command.go:968
main.runInteractive({{0xc000e32ed0, 0xc000e33f50, 0xc000e33230, 0xc000e32b70}, {{0x62acd07, 0xc}, {0x63bbff1, 0x2f}, {0x632f679, 0x1d}}, ...})
        github.com/SumoLogic/sumologic-otel-collector/main.go:37 +0x7d
main.run(...)
        github.com/SumoLogic/sumologic-otel-collector/main_others.go:11
main.main()
        github.com/SumoLogic/sumologic-otel-collector/main.go:25 +0x1d8

@github-actions github-actions bot added the go label Jan 30, 2023
@swiatekm swiatekm force-pushed the fix/telegrafreceiver/shutdown branch from dd644fb to ce17915 Compare January 30, 2023 12:02
@swiatekm swiatekm marked this pull request as ready for review January 30, 2023 12:02
@swiatekm swiatekm requested a review from a team as a code owner January 30, 2023 12:02
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jan 30, 2023
@swiatekm swiatekm force-pushed the fix/telegrafreceiver/shutdown branch from ce17915 to e37954f Compare January 30, 2023 12:09
@swiatekm swiatekm enabled auto-merge (rebase) January 30, 2023 12:09
@swiatekm swiatekm merged commit 588e0c0 into main Jan 30, 2023
@swiatekm swiatekm deleted the fix/telegrafreceiver/shutdown branch January 30, 2023 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation go
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants