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

Application with Sentry logger fails to remove ThreadLocal when app is stopped on Tomcat #420

Closed
wojciechmusial opened this issue Jun 19, 2017 · 3 comments

Comments

@wojciechmusial
Copy link

I'm using Tomcat 8 and lastest version of Sentry SDK:

<dependency>
      <groupId>io.sentry</groupId>
      <artifactId>sentry-log4j2</artifactId>
      <version>1.1.0</version>
</dependency>

I configured my logging in files:

log4j2.properties

appender.console.type=Console
appender.console.name=STDOUT
appender.console.layout.type=PatternLayout
appender.console.layout.pattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

appender.sentry.type=Sentry
appender.sentry.name=Sentry

rootLogger.level=WARN
rootLogger.appenderRef.stdout.ref=STDOUT
rootLogger.appenderRef.sentry.ref=Sentry
rootLogger.appenderRef.sentry.level=WARN

sentry.properties

dsn=<my_sentry_dsn>
async.gracefulshutdown=false

I assumed that using async.gracefulshutdown=false will kill all running threads properly, so that my application is not exposed to any memory leak problems. When I redeploy my application Tomcat is reporting that ThreadLocal connected to Sentry failed to be removed:

19-Jun-2017 22:06:57.423 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [io.sentry.context.ThreadLocalContextManager$1] (value [io.sentry.context.ThreadLocalContextManager$1@5d7c6e1d]) and a value of type [io.sentry.context.Context] (value [io.sentry.context.Context@40c92b58]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

Is there something that could be done in reference to above issue?

@bretthoerner
Copy link

Thanks for the report, I'll check this out ASAP. I haven't done a lot of testing with full blown application servers, I think this should hopefully be a quick fix tomorrow.

@bretthoerner
Copy link

Merged something that should fix this, releasing soon.

@wukrwurk
Copy link

wukrwurk commented Jun 1, 2022

I got a similar issue with Tomcat 9 and sentry 5.3.7

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

No branches or pull requests

3 participants