Replies: 1 comment
-
@maciejwalkowiak will investigate if/how Tomcat shares recources between web apps. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm not sure whether this should be a bug ticket instead, or whether I'm just blind and missing something. That's why I post this as a discussion / question.
TL;DR
Sentry.close()
method cannot be used, since it completely shuts down the Sentry integration for entire applicationLong Version
I have a problem with the latest Sentry SDK used in a JAX-RS web application (Apache CXF + Spring on Tomcat 9). When the application is reloaded due to a redeploy, I get repeatedly the following warning:
I found the following PR that was supposed to fix this problem:
#1909
After a bit of debugging and poking around, I have a feeling this is caused by Sentry being used within request threads (either for capturing error events, or for performance analytics). The Sentry singleton has a thread local variable for keeping separate Hub instances per thread. These thread local hub copies are never cleaned up.
I implemented an application context listener that calls
Sentry.close()
when the context is closed. The Sentry.close method does remove the hub threadlocal. But only the one for the thread that is responsible for closing the servlet context. The Sentry Hub instances that were in use by the request threads are not removed.I could set up a request listener that would try to clean up the Sentry hub when a request has finished, but that would probably defy the purpose of caching those hubs per thread, and eventually come with some overhead of recreating them?
Also, if I would call
Sentry.close()
after a request has finished, then this would shut down the entire Sentry integration, and the global hub, so given the current Sentry SDK implementation, that doesn't seem to be possible. There needs to be a public API for only removing thecurrentHub
thread local for the current thread, without unregistering everything.Even if the Sentry SDK had a mechanism for just removing the hub for the current thread, I don't know if Java's servlet API has a mechanism for running cleanup code when request threads are shut down.
I'm a bit at a loss here, and I would like to know how to correctly integrate and configure Sentry so it doesn't leak memory over time
Beta Was this translation helpful? Give feedback.
All reactions