0

我们有一张表,里面大概有5亿条数据,查询都是走了索引的,在生产上偶尔出现读超时,mongodb服务器未见cpu,网络,内存性能问题,初步判断是查询语句问题

1.我们使用的是阿里云的云mongodb服务器

2.问题就是查询语句超时的,看慢查询日志再次查询速度很快

3.mongod是主从复制的集群模式,1主1副2读节点

求问题的可能原因,谢谢

错误日志如下:

CauseBy: com.mongodb.connection.InternalStreamConnection.translateReadException(InternalStreamConnection.java:530)
com.mongodb.connection.InternalStreamConnection.receiveMessage(InternalStreamConnection.java:421)
com.mongodb.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:290)
com.mongodb.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:255)
com.mongodb.connection.UsageTrackingInternalConnection.sendAndReceive(UsageTrackingInternalConnection.java:98)
com.mongodb.connection.DefaultConnectionPool$PooledConnection.sendAndReceive(DefaultConnectionPool.java:441)
com.mongodb.connection.CommandProtocolImpl.execute(CommandProtocolImpl.java:76)
com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:189)
com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:263)
com.mongodb.connection.DefaultServerConnection.command(DefaultServerConnection.java:126)
com.mongodb.connection.DefaultServerConnection.command(DefaultServerConnection.java:118)
com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:226)
com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:217)
com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:120)
com.mongodb.operation.FindOperation$1.call(FindOperation.java:717)
com.mongodb.operation.FindOperation$1.call(FindOperation.java:711)
com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:470)
com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:414)
com.mongodb.operation.FindOperation.execute(FindOperation.java:711)
com.mongodb.operation.FindOperation.execute(FindOperation.java:83)
com.mongodb.Mongo$3.execute(Mongo.java:822)
com.mongodb.MongoIterableImpl.execute(MongoIterableImpl.java:130)
com.mongodb.MongoIterableImpl.iterator(MongoIterableImpl.java:77)
com.mongodb.MongoIterableImpl.forEach(MongoIterableImpl.java:100)
com.ants.familymonitor.interfaces.service.impl.MessageService.getMessageDto(MessageService.java:85)
com.ants.familymonitor.interfaces.service.impl.UserLoginMessageService.getAllLoginMessages(UserLoginMessageService.java:86)
sun.reflect.GeneratedMethodAccessor172.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
com.sun.proxy.$Proxy68.getAllLoginMessages(Unknown Source)
com.ants.familymonitor.interfaces.controller.V5UserInterfaceController.searchUserLoginInfos(V5UserInterfaceController.java:145)
sun.reflect.GeneratedMethodAccessor171.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:743)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:672)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:82)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:933)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:867)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:951)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:842)
javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:827)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
com.alibaba.csp.sentinel.adapter.servlet.CommonFilter.doFilter(CommonFilter.java:110)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:748)

已回答的问题