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
NPE in MongoMetricsConnectionPoolListener on shutdown #2384
Comments
@Stephan202 Can you confirm if the fix for #2117 resolved the issue in your case? |
Your analysis makes sense given the stacktrace, but it does seem odd that a |
MongoMetricsConnectionPoolListener
againMongoMetricsConnectionPoolListener
on shutdown
@jshields-squarespace @shakuzen thanks for pinging me. I just checked our company logs over the past month, and indeed, while the issue no longer happens in apps against which it was first reported, one of our applications in particular does log these NPEs. (~All our applications, including this particular one, are on Micrometer 1.6.0.) I've asked the associated team whether maybe they're aware of a slightly different usage of either MongoDB or Micrometer, compared to other applications. |
Heard back. The team doesn't use MongoDB differently from our other applications, but what does set it apart is its use of GraalVM rather than OpenJDK. I suppose that might make certain race conditions more apparent. |
Update: this morning I missed part of our logs due to a misapplied filter (yeah... ☕). Now did a more thorough seach and unfortunately we also still see the NPEs on other applications, so indeed the issue is not fixed. (The aforementioned GraalVM application ran in a crash loop on the previously selected environment, which merely made the problem more pronounced there.) |
@Stephan202 Thanks for the confirmation. @shakuzen Yes, my suspicion is that these threads in our application continue to run during application shutdown, rather than stopping and cleaning up nicely before shutdown proceeds. And so the connection pool is closed out from underneath them. While that might be an unideal app behavior, I wonder if Micrometer should be resilient to it all the same. |
Logically, the other events should not happen after the connection pool has been closed, but it seems they sometimes do. When they do (e.g. on shutdown), a NPE was being thrown. This change guards against such NPEs. Resolves micrometer-metricsgh-2384
MongoMetricsConnectionPoolListener
on shutdown
With Micrometer 1.3.14, during application shutdown we get NPEs from
MongoMetricsConnectionPoolListener
.This looks related to #2117. However that was supposedly fixed in 1.3.10, and we're experiencing this issue with 1.3.14.
It seems like
checkedOutCount
no longer has an entry for the server ID, presumably becauseconnectionPoolClosed
was already called during the application shutdown.Stack trace:
I'm not sure if it's useful information, but it seems like in our case these NPEs are exclusively being thrown in threads that are created via a
ScheduledTaskRegistrar
orAsyncListenableTaskExecutor
—the latter from Spring Kafka.The text was updated successfully, but these errors were encountered: