-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Collector Shutdown will not be honored if called to early #4843
Comments
Why don't we create shutdownChan in New |
I think we should but I also think we might need a new state to indicate the collector has been created but not started. If |
That's right, we should also recreate |
I think I might be missing the reasoning for this. The collector is meant to be one time use. Recreating the Please let me know if I'm missing something on the reasoning for recreating the |
If the collector is meant to be one time use, it's unnecessary to recreate shutdownChan. But we should check |
Makes sense. I'll try to start on a solution this week for this. Thanks for discussing. |
Describe the bug
There's a race condition in when calling
Collector.Shutdown
right after callingCollector.Run
. Since the shutdownChan isn't initialized until startup has finished here. Any call toShutdown
whileRun
is in this section of execution will cause run to attempt to close a nil channel. This causes a panic which is caught but the shutdown call is effectively ignored and the collector will run as normal even though shutdown was called.Steps to reproduce
Because this is a race condition it's hard to time but possibly rapidly calling
Run
thenShutdown
could trigger it.What did you expect to see?
Calling
Shutdown
at any point after callingRun
should cause the collector to shutdown.What did you see instead?
Again race condition but if you get the timing right you can call
Shutdown
and the collector will continue to run.What version did you use?
v0.44.0
What config did you use?
Any valid config will work
Environment
OS: macOS Monterey 12.2
Additional context
I think a full solution would add a new state to collector states that indicate the collector has been created but never run. Maybe just a
Created
state. With that you can init theshutdownChan
with the collector andShutdown
can check to close the channel only if the collector is in aStarted
orRunning
state, else it's a noop.The text was updated successfully, but these errors were encountered: