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

Avoiding app shutdown race condition #449

Merged
merged 1 commit into from
Jun 21, 2023
Merged

Avoiding app shutdown race condition #449

merged 1 commit into from
Jun 21, 2023

Conversation

kyleboon
Copy link
Contributor

When an application received SIGTERM, if the data dog agent has not completely finished it's initialization, adding the shutdown hook results in an exception. Catching the exception and stopping the initialization process should avoid this.

Example stack trace when this happens:

java.lang.IllegalStateException: Shutdown in progress
	at java.base/java.lang.ApplicationShutdownHooks.add(Unknown Source)
	at java.base/java.lang.Runtime.addShutdownHook(Unknown Source)
	at org.datadog.jmxfetch.App.run(App.java:154)
	at datadog.trace.agent.jmxfetch.JMXFetch$1.run(JMXFetch.java:131)
	at java.base/java.lang.Thread.run(Unknown Source)

When an application received SIGTERM, if the data dog agent
has not completely finished it's initialization, adding the
shutdown hook results in an exception. Catching the exception
and stopping the initialization process should avoid this.

Example stack trace when this happens:

```
java.lang.IllegalStateException: Shutdown in progress
	at java.base/java.lang.ApplicationShutdownHooks.add(Unknown Source)
	at java.base/java.lang.Runtime.addShutdownHook(Unknown Source)
	at org.datadog.jmxfetch.App.run(App.java:154)
	at datadog.trace.agent.jmxfetch.JMXFetch$1.run(JMXFetch.java:131)
	at java.base/java.lang.Thread.run(Unknown Source)
```
Copy link
Contributor

@scottopell scottopell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@scottopell scottopell merged commit 1d37422 into DataDog:master Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants