gzshilu opened a new pull request #2827: Improve ContextManager class of sniffer module URL: https://github.com/apache/skywalking/pull/2827 Please answer these questions before submitting pull request - Why submit this pull request? - [X] Bug fix - [ ] New feature provided - [ ] Improve performance - Related issues ___ ### Bug fix - Bug description. This problem is caused by the threadlocal variable。In most cases, a thread in application server does not exist Independent. It does exist in thread-pool. The threads in the thread pool are reused, so if the value in thedaoLocal is not removed in time, it happens. After a new request, it may get an old value。 At SpringMvc plugins, `org.apache.skywalking.apm.plugin.spring.mvc.commons.interceptorStackDepth` has never been removed, so this bug was be happened. **·How to reproduce ?** 1. `Remove tomcat plugin (undertow, jetty-server)` 2. Restart my application 3. Repeat the request for the same interface multiple times with postman or jmeter. You will see that the operation-name of current trace segment is the method name, not the request url. And EntrySpan becomes LocalSpan. I think this is unreasonable. Because I have removed all the application container plugins, spring mvc is the first interceptor , so EntrySpan is Right ,not LocalSpan。 - How to fix? I think it's more troublesome to fix this problem in spring mvc plugins. If you remove `StackDepth` there, It may generate new problems. so I think modify ContextManager.stopSpan() is best way.Also remove `RUNTIME_CONTEXT` while removing `CONTEXT` like this: ```java public static void stopSpan(AbstractSpan span) { if (get().stopSpan(span)) { CONTEXT.remove(); // add RUNTIME_CONTEXT.remove(); } } ``` ___ ### New feature or improvement - Describe the details and related test reports. This modification has been verified locally.
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
