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

SDK race condition when only scheduled tasks #37

Open
sdewitt-newrelic opened this issue Oct 2, 2024 · 0 comments
Open

SDK race condition when only scheduled tasks #37

sdewitt-newrelic opened this issue Oct 2, 2024 · 0 comments

Comments

@sdewitt-newrelic
Copy link
Contributor

There is a race condition in the SDK that occurs when there are only scheduled tasks and no components and when the integration is running as a service and when you ctrl-C the integration.

When there are no components , the executor go routine is never spawned. The executor thread keeps the wait group alive until the last line of Shutdown() so the integration can shutdown properly. Without the executor, as soon as the last scheduled component shuts down, the wait group is released. This is fine under normal circumstances because Shutdown() is supposed to be called by the integration main() routine when control returns from Run(). But when you ctrl-C, the SDK calls Shutdown() automatically but it occurs in the thread that is handling the interrupt. So without components, the Shutdown() call can end up running in parallel with the main thread which is exiting. The main thread often will win which means Shutdown() doesn't complete and the integration doesn't gracefully shutdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

1 participant