apache / skywalking

APM, Application Performance Monitoring System
https://skywalking.apache.org/
Apache License 2.0
23.64k stars 6.49k forks source link

class[class com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor] before method[execute] intercept failure java.lang.NullPointerException #5070

Closed carrypann closed 4 years ago

carrypann commented 4 years ago

Please answer these questions before submitting your issue.


Bug

And skywalking print error log:

ERROR 2020-07-09 16:00:00:146 scheduling-1 InstMethodsInter : class[class com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor] before method[execute] intercept failure 
java.lang.NullPointerException
    at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936)
    at org.apache.skywalking.apm.agent.core.dictionary.NetworkAddressDictionary.find(NetworkAddressDictionary.java:44)
    at org.apache.skywalking.apm.agent.core.context.TracingContext.createExitSpan(TracingContext.java:388)
    at org.apache.skywalking.apm.agent.core.context.ContextManager.createExitSpan(ContextManager.java:120)
    at org.apache.skywalking.apm.plugin.mongodb.v3.support.MongoSpanHelper.createExitSpan(MongoSpanHelper.java:39)
    at org.apache.skywalking.apm.plugin.mongodb.v3.interceptor.v37.MongoDBOperationExecutorInterceptor.beforeMethod(MongoDBOperationExecutorInterceptor.java:51)
    at org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstMethodsInter.intercept(InstMethodsInter.java:82)
    at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java)
    at com.mongodb.client.internal.MongoIterableImpl.execute(MongoIterableImpl.java:135)
    at com.mongodb.client.internal.MongoIterableImpl.iterator(MongoIterableImpl.java:92)
    at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:2771)
    at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:2507)
    at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:2489)
    at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:856)
        ......
InstMethodsInter : class[class com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor] after method[execute] intercept failure 
java.lang.IllegalStateException: No active span.
    at org.apache.skywalking.apm.agent.core.context.TracingContext.activeSpan(TracingContext.java:414)
    at org.apache.skywalking.apm.agent.core.context.ContextManager.stopSpan(ContextManager.java:182)
    at org.apache.skywalking.apm.plugin.mongodb.v3.interceptor.v37.MongoDBOperationExecutorInterceptor.afterMethod(MongoDBOperationExecutorInterceptor.java:57)
    at org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstMethodsInter.intercept(InstMethodsInter.java:105)
    at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java)
    at com.mongodb.client.internal.MongoCollectionImpl.executeFindOneAndUpdate(MongoCollectionImpl.java:752)
    at com.mongodb.client.internal.MongoCollectionImpl.findOneAndUpdate(MongoCollectionImpl.java:732)
    at com.mongodb.client.internal.MongoCollectionImpl.findOneAndUpdate(MongoCollectionImpl.java:726)

Is it caused by incompatibility with mongodb-driver 4.0+,or other reason?

wu-sheng commented 4 years ago

Check the supported-list doc for supported versions. I only found the MongoDB 3.x test cases, https://github.com/apache/skywalking/tree/master/test/plugin/scenarios/mongodb-3.x-scenario. Most likely, there is no one contributed 4.x plugins yet.

Welcome everyone to do so.

carrypann commented 4 years ago

I mean, this problem may not caused by MongoDB4.0+, or how can I check the actual reason? So that I can try to contribute 4.x plugins

wu-sheng commented 4 years ago

It could be triggered by other plugins issue. You could try to remove the MongoDB plugin, and give a try. If there is no issue, then, most likely it is the plugin issue. But, as always, debugging is always the best choice.

carrypann commented 4 years ago

Thx, I've checked source code and confirm that the reason is plugin incompatibility. mongodb-4.x-plugin is needed because SpringBoot 2.3 release switches to MongoDB 4