Title: Virtual thread pinning on MainEventProcessor.ensureHostnameCache · Issue #3312 · getsentry/sentry-java · GitHub
Open Graph Title: Virtual thread pinning on MainEventProcessor.ensureHostnameCache · Issue #3312 · getsentry/sentry-java
X Title: Virtual thread pinning on MainEventProcessor.ensureHostnameCache · Issue #3312 · getsentry/sentry-java
Description: Problem Statement We use Java 21 and Spring Boot 3.2.4 with enabled virtual threads in plain web application. First request after app init leads to thread pinning: io.sentry.MainEventProcessor.ensureHostnameCache(MainEventProcessor.java:...
Open Graph Description: Problem Statement We use Java 21 and Spring Boot 3.2.4 with enabled virtual threads in plain web application. First request after app init leads to thread pinning: io.sentry.MainEventProcessor.ensu...
X Description: Problem Statement We use Java 21 and Spring Boot 3.2.4 with enabled virtual threads in plain web application. First request after app init leads to thread pinning: io.sentry.MainEventProcessor.ensu...
Opengraph URL: https://github.com/getsentry/sentry-java/issues/3312
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Virtual thread pinning on MainEventProcessor.ensureHostnameCache","articleBody":"### Problem Statement\n\nWe use Java 21 and Spring Boot 3.2.4 with enabled virtual threads in plain web application. First request after app init leads to thread pinning: ` io.sentry.MainEventProcessor.ensureHostnameCache(MainEventProcessor.java:192) \u003c== monitors:1`. Subsequent requests are fine.\r\n```java\r\nThread[#143,ForkJoinPool-1-worker-1,5,CarrierThreads]\r\n java.base/java.lang.VirtualThread$VThreadContinuation.onPinned(VirtualThread.java:185)\r\n java.base/jdk.internal.vm.Continuation.onPinned0(Continuation.java:393)\r\n java.base/java.lang.VirtualThread.parkNanos(VirtualThread.java:631)\r\n java.base/java.lang.System$2.parkVirtualThread(System.java:2648)\r\n java.base/jdk.internal.misc.VirtualThreads.park(VirtualThreads.java:67)\r\n java.base/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:267)\r\n java.base/java.util.concurrent.FutureTask.awaitDone(FutureTask.java:497)\r\n java.base/java.util.concurrent.FutureTask.get(FutureTask.java:203)\r\n io.sentry.HostnameCache.updateCache(HostnameCache.java:121)\r\n io.sentry.HostnameCache.\u003cinit>(HostnameCache.java:77)\r\n io.sentry.HostnameCache.\u003cinit>(HostnameCache.java:64)\r\n io.sentry.HostnameCache.\u003cinit>(HostnameCache.java:58)\r\n io.sentry.HostnameCache.getInstance(HostnameCache.java:52)\r\n io.sentry.MainEventProcessor.ensureHostnameCache(MainEventProcessor.java:192) \u003c== monitors:1\r\n io.sentry.MainEventProcessor.setServerName(MainEventProcessor.java:181)\r\n io.sentry.MainEventProcessor.processNonCachedEvent(MainEventProcessor.java:132)\r\n io.sentry.MainEventProcessor.process(MainEventProcessor.java:146)\r\n io.sentry.SentryClient.processTransaction(SentryClient.java:416)\r\n io.sentry.SentryClient.captureTransaction(SentryClient.java:661)\r\n io.sentry.Hub.captureTransaction(Hub.java:700)\r\n io.sentry.SentryTracer.finish(SentryTracer.java:264)\r\n io.sentry.SentryTracer.finish(SentryTracer.java:565)\r\n io.sentry.SentryTracer.finish(SentryTracer.java:558)\r\n io.sentry.SentryTracer.finish(SentryTracer.java:553)\r\n io.sentry.spring.jakarta.tracing.SentryTracingFilter.doFilterWithTransaction(SentryTracingFilter.java:127)\r\n io.sentry.spring.jakarta.tracing.SentryTracingFilter.doFilterInternal(SentryTracingFilter.java:87)\r\n org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)\r\n org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)\r\n org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)\r\n org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)\r\n org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)\r\n org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)\r\n org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)\r\n io.sentry.spring.jakarta.SentrySpringFilter.doFilterInternal(SentrySpringFilter.java:71)\r\n org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)\r\n org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)\r\n org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)\r\n org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167)\r\n org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)\r\n org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)\r\n org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115)\r\n org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)\r\n org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)\r\n org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)\r\n org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391)\r\n org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)\r\n org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896)\r\n org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1744)\r\n org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)\r\n java.base/java.lang.VirtualThread.run(VirtualThread.java:311)\r\n```\r\nThis behavior is observed in Sentry 7.6.0 and 6.26.0 \n\n### Solution Brainstorm\n\nWould be nice if Sentry became Loom-friendly and replace synchronized methods to ReentrantLock for virtual thread support.\r\n\r\nFrom this\r\n```java\r\nprivate void ensureHostnameCache() {\r\n if (hostnameCache == null) {\r\n synchronized (this) {\r\n if (hostnameCache == null) {\r\n hostnameCache = HostnameCache.getInstance();\r\n }\r\n }\r\n }\r\n }\r\n```\r\n\r\nTo this:\r\n```java\r\n private final ReentrantLock lock = new ReentrantLock();\r\n\r\n private void ensureHostnameCache() {\r\n if (hostnameCache == null) {\r\n lock.lock();\r\n try {\r\n if (hostnameCache == null) {\r\n hostnameCache = HostnameCache.getInstance();\r\n }\r\n } finally {\r\n lock.unlock();\r\n }\r\n }\r\n }\r\n```","author":{"url":"https://github.com/pavelbelonosov","@type":"Person","name":"pavelbelonosov"},"datePublished":"2024-04-02T15:24:00Z","url":"https://github.com/getsentry/sentry-java/issues/3312"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fab2944d-6d74-660a-e824-8bdd66b32417 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8470:3ABDFB:7710B9:A29CC1:6B0479FD |
| html-safe-nonce | 14fc418bfe3dcc494bc4601b83a39a4ae0fcea40b0915b9fd969d42d332f735a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NDcwOjNBQkRGQjo3NzEwQjk6QTI5Q0MxOjZCMDQ3OUZEIiwidmlzaXRvcl9pZCI6IjU0NjczOTk4Mjk1MTA3MTU5MDEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 597da57ec912c0bb320f520370aae1880930cc15cfe9178eb904d2c2e14efe68 |
| hovercard-subject-tag | issue:2220812434 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-java/3312/issue_layout |
| twitter:image | https://opengraph.githubassets.com/adbd9e3470209ad96fe055b85f1c2794732bfcfead796ddb3feeca981142a86a/getsentry/sentry-java/issues/3312 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/adbd9e3470209ad96fe055b85f1c2794732bfcfead796ddb3feeca981142a86a/getsentry/sentry-java/issues/3312 |
| og:image:alt | Problem Statement We use Java 21 and Spring Boot 3.2.4 with enabled virtual threads in plain web application. First request after app init leads to thread pinning: io.sentry.MainEventProcessor.ensu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pavelbelonosov |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9c099f1b85def81ca352464c276510dfef32deaf3c305404e65b8d270284a58b |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-java git https://github.com/getsentry/sentry-java.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3368190 |
| octolytics-dimension-repository_nwo | getsentry/sentry-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3368190 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cf73f57448d52b3a7b619195e182b33d3b3454ca |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width