MongoDB query field does not create an index for Connection Timeout exception solution case sharing _mongodb

Source: Internet
Author: User
Tags aop findone mongodb mongodb query socket apache tomcat

Today in the scene of the brother sent an exception, let me resolve the error message is as follows:

Copy Code code as follows:

HTTP Status 500-read operation to server 192.168.1.110:20001 failed on database wpdb; Nested exception is com.mongodb.mongoexception$network:read operation to server 192.168.1.110:20001 failed on database WP Db

--------------------------------------------------------------------------------

Type Exception

Message Read operation to server 192.168.1.110:20001 failed on database wpdb; Nested exception is com.mongodb.mongoexception$network:read operation to server 192.168.1.110:20001 failed on database WP Db

Description the "server encountered an internal error" prevented it from fulfilling this request.

exception

Org.springframework.dao.DataAccessResourceFailureException:Read operation to server 192.168.1.110:20001 failed on Database wpdb; Nested exception is com.mongodb.mongoexception$network:read operation to server 192.168.1.110:20001 failed on database WP Db
Org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible ( MONGOEXCEPTIONTRANSLATOR.JAVA:56)
Org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException (mongotemplate.java:1913 )
Org.springframework.data.mongodb.core.MongoTemplate.executeFindOneInternal (mongotemplate.java:1743)
Org.springframework.data.mongodb.core.MongoTemplate.doFindOne (mongotemplate.java:1557)
Org.springframework.data.mongodb.core.MongoTemplate.findOne (mongotemplate.java:497)
Com.geoway.ime.tile.dao.impl.TileDaoImpl.getTile (TILEDAOIMPL.JAVA:60)
Com.geoway.ime.tile.service.impl.TileServiceImpl.getTile (tileserviceimpl.java:105)
Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native method)
Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:39)
Sun.reflect.DelegatingMethodAccessorImpl.invoke (DELEGATINGMETHODACCESSORIMPL.JAVA:25)
Java.lang.reflect.Method.invoke (method.java:597)
Org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection (aoputils.java:317)
Org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint (Reflectivemethodinvocation.java : 183)
Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (reflectivemethodinvocation.java:150)
Org.springframework.cache.interceptor.cacheinterceptor$1.invoke (cacheinterceptor.java:58)
Org.springframework.cache.interceptor.CacheAspectSupport.execute (cacheaspectsupport.java:211)
Org.springframework.cache.interceptor.CacheInterceptor.invoke (cacheinterceptor.java:66)
Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (reflectivemethodinvocation.java:172)
Org.springframework.aop.framework.JdkDynamicAopProxy.invoke (jdkdynamicaopproxy.java:204)
Com.sun.proxy. $Proxy 50.getTile (Unknown Source)
Com.geoway.ime.server.rest.TileServer.getTileKVP (TILESERVER.JAVA:60)
Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native method)
Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:39)
Sun.reflect.DelegatingMethodAccessorImpl.invoke (DELEGATINGMETHODACCESSORIMPL.JAVA:25)
Java.lang.reflect.Method.invoke (method.java:597)
Com.sun.jersey.spi.container.javamethodinvokerfactory$1.invoke (JAVAMETHODINVOKERFACTORY.JAVA:60)
Com.sun.jersey.server.impl.model.method.dispatch.abstractresourcemethoddispatchprovider$typeoutinvoker._ Dispatch (abstractresourcemethoddispatchprovider.java:185)
Com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch ( RESOURCEJAVAMETHODDISPATCHER.JAVA:75)
Com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept (httpmethodrule.java:302)
Com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept (resourceclassrule.java:108)
Com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept (righthandpathrule.java:147)
Com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept (rootresourceclassesrule.java:84)
Com.sun.jersey.server.impl.application.webapplicationimpl._handlerequest (webapplicationimpl.java:1511)
Com.sun.jersey.server.impl.application.webapplicationimpl._handlerequest (webapplicationimpl.java:1442)
Com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest (webapplicationimpl.java:1391)
Com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest (webapplicationimpl.java:1381)
Com.sun.jersey.spi.container.servlet.WebComponent.service (webcomponent.java:416)
Com.sun.jersey.spi.container.servlet.ServletContainer.service (servletcontainer.java:538)
Com.sun.jersey.spi.container.servlet.ServletContainer.service (servletcontainer.java:716)
Javax.servlet.http.HttpServlet.service (httpservlet.java:723)
Org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal (characterencodingfilter.java:88)
Org.springframework.web.filter.OncePerRequestFilter.doFilter (onceperrequestfilter.java:106)


Root cause

Com.mongodb.mongoexception$network:read operation to server 192.168.1.110:20001 failed on database wpdb
Com.mongodb.DBTCPConnector.innerCall (dbtcpconnector.java:308)
Com.mongodb.DBTCPConnector.call (dbtcpconnector.java:279)
Com.mongodb.DBCollectionImpl.find (dbcollectionimpl.java:84)
Com.mongodb.DBCollectionImpl.find (dbcollectionimpl.java:66)
Com.mongodb.DBCollection.findOne (dbcollection.java:870)
Com.mongodb.DBCollection.findOne (dbcollection.java:844)
Com.mongodb.DBCollection.findOne (dbcollection.java:790)
Org.springframework.data.mongodb.core.mongotemplate$findonecallback.doincollection (MongoTemplate.java:1980)
Org.springframework.data.mongodb.core.mongotemplate$findonecallback.doincollection (MongoTemplate.java:1965)
Org.springframework.data.mongodb.core.MongoTemplate.executeFindOneInternal (mongotemplate.java:1739)
Org.springframework.data.mongodb.core.MongoTemplate.doFindOne (mongotemplate.java:1557)
Org.springframework.data.mongodb.core.MongoTemplate.findOne (mongotemplate.java:497)
Com.geoway.ime.tile.dao.impl.TileDaoImpl.getTile (TILEDAOIMPL.JAVA:60)
Com.geoway.ime.tile.service.impl.TileServiceImpl.getTile (tileserviceimpl.java:105)
Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native method)
Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:39)
Sun.reflect.DelegatingMethodAccessorImpl.invoke (DELEGATINGMETHODACCESSORIMPL.JAVA:25)
Java.lang.reflect.Method.invoke (method.java:597)
Org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection (aoputils.java:317)
Org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint (Reflectivemethodinvocation.java : 183)
Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (reflectivemethodinvocation.java:150)
Org.springframework.cache.interceptor.cacheinterceptor$1.invoke (cacheinterceptor.java:58)
Org.springframework.cache.interceptor.CacheAspectSupport.execute (cacheaspectsupport.java:211)
Org.springframework.cache.interceptor.CacheInterceptor.invoke (cacheinterceptor.java:66)
Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (reflectivemethodinvocation.java:172)
Org.springframework.aop.framework.JdkDynamicAopProxy.invoke (jdkdynamicaopproxy.java:204)
Com.sun.proxy. $Proxy 50.getTile (Unknown Source)
Com.geoway.ime.server.rest.TileServer.getTileKVP (TILESERVER.JAVA:60)
Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native method)
Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:39)
Sun.reflect.DelegatingMethodAccessorImpl.invoke (DELEGATINGMETHODACCESSORIMPL.JAVA:25)
Java.lang.reflect.Method.invoke (method.java:597)
Com.sun.jersey.spi.container.javamethodinvokerfactory$1.invoke (JAVAMETHODINVOKERFACTORY.JAVA:60)
Com.sun.jersey.server.impl.model.method.dispatch.abstractresourcemethoddispatchprovider$typeoutinvoker._ Dispatch (abstractresourcemethoddispatchprovider.java:185)
Com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch ( RESOURCEJAVAMETHODDISPATCHER.JAVA:75)
Com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept (httpmethodrule.java:302)
Com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept (resourceclassrule.java:108)
Com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept (righthandpathrule.java:147)
Com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept (rootresourceclassesrule.java:84)
Com.sun.jersey.server.impl.application.webapplicationimpl._handlerequest (webapplicationimpl.java:1511)
Com.sun.jersey.server.impl.application.webapplicationimpl._handlerequest (webapplicationimpl.java:1442)
Com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest (webapplicationimpl.java:1391)
Com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest (webapplicationimpl.java:1381)
Com.sun.jersey.spi.container.servlet.WebComponent.service (webcomponent.java:416)
Com.sun.jersey.spi.container.servlet.ServletContainer.service (servletcontainer.java:538)
Com.sun.jersey.spi.container.servlet.ServletContainer.service (servletcontainer.java:716)
Javax.servlet.http.HttpServlet.service (httpservlet.java:723)
Org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal (characterencodingfilter.java:88)
Org.springframework.web.filter.OncePerRequestFilter.doFilter (onceperrequestfilter.java:106)


Root cause

Java.net.SocketTimeoutException:Read timed out
Java.net.SocketInputStream.socketRead0 (Native method)
Java.net.SocketInputStream.read (socketinputstream.java:129)
Java.io.BufferedInputStream.fill (bufferedinputstream.java:218)
Java.io.BufferedInputStream.read1 (bufferedinputstream.java:258)
Java.io.BufferedInputStream.read (bufferedinputstream.java:317)
Org.bson.io.Bits.readFully (bits.java:48)
Org.bson.io.Bits.readFully (bits.java:35)
Org.bson.io.Bits.readFully (bits.java:30)
Com.mongodb.response.<init> (response.java:42)
Com.mongodb.dbport$1.execute (dbport.java:141)
Com.mongodb.dbport$1.execute (dbport.java:135)
Com.mongodb.DBPort.doOperation (dbport.java:164)
Com.mongodb.DBPort.call (dbport.java:135)
Com.mongodb.DBTCPConnector.innerCall (dbtcpconnector.java:300)
Com.mongodb.DBTCPConnector.call (dbtcpconnector.java:279)
Com.mongodb.DBCollectionImpl.find (dbcollectionimpl.java:84)
Com.mongodb.DBCollectionImpl.find (dbcollectionimpl.java:66)
Com.mongodb.DBCollection.findOne (dbcollection.java:870)
Com.mongodb.DBCollection.findOne (dbcollection.java:844)
Com.mongodb.DBCollection.findOne (dbcollection.java:790)
Org.springframework.data.mongodb.core.mongotemplate$findonecallback.doincollection (MongoTemplate.java:1980)
Org.springframework.data.mongodb.core.mongotemplate$findonecallback.doincollection (MongoTemplate.java:1965)
Org.springframework.data.mongodb.core.MongoTemplate.executeFindOneInternal (mongotemplate.java:1739)
Org.springframework.data.mongodb.core.MongoTemplate.doFindOne (mongotemplate.java:1557)
Org.springframework.data.mongodb.core.MongoTemplate.findOne (mongotemplate.java:497)
Com.geoway.ime.tile.dao.impl.TileDaoImpl.getTile (TILEDAOIMPL.JAVA:60)
Com.geoway.ime.tile.service.impl.TileServiceImpl.getTile (tileserviceimpl.java:105)
Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native method)
Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:39)
Sun.reflect.DelegatingMethodAccessorImpl.invoke (DELEGATINGMETHODACCESSORIMPL.JAVA:25)
Java.lang.reflect.Method.invoke (method.java:597)
Org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection (aoputils.java:317)
Org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint (Reflectivemethodinvocation.java : 183)
Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (reflectivemethodinvocation.java:150)
Org.springframework.cache.interceptor.cacheinterceptor$1.invoke (cacheinterceptor.java:58)
Org.springframework.cache.interceptor.CacheAspectSupport.execute (cacheaspectsupport.java:211)
Org.springframework.cache.interceptor.CacheInterceptor.invoke (cacheinterceptor.java:66)
Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (reflectivemethodinvocation.java:172)
Org.springframework.aop.framework.JdkDynamicAopProxy.invoke (jdkdynamicaopproxy.java:204)
Com.sun.proxy. $Proxy 50.getTile (Unknown Source)
Com.geoway.ime.server.rest.TileServer.getTileKVP (TILESERVER.JAVA:60)
Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native method)
Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:39)
Sun.reflect.DelegatingMethodAccessorImpl.invoke (DELEGATINGMETHODACCESSORIMPL.JAVA:25)
Java.lang.reflect.Method.invoke (method.java:597)
Com.sun.jersey.spi.container.javamethodinvokerfactory$1.invoke (JAVAMETHODINVOKERFACTORY.JAVA:60)
Com.sun.jersey.server.impl.model.method.dispatch.abstractresourcemethoddispatchprovider$typeoutinvoker._ Dispatch (abstractresourcemethoddispatchprovider.java:185)
Com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch ( RESOURCEJAVAMETHODDISPATCHER.JAVA:75)
Com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept (httpmethodrule.java:302)
Com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept (resourceclassrule.java:108)
Com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept (righthandpathrule.java:147)
Com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept (rootresourceclassesrule.java:84)
Com.sun.jersey.server.impl.application.webapplicationimpl._handlerequest (webapplicationimpl.java:1511)
Com.sun.jersey.server.impl.application.webapplicationimpl._handlerequest (webapplicationimpl.java:1442)
Com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest (webapplicationimpl.java:1391)
Com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest (webapplicationimpl.java:1381)
Com.sun.jersey.spi.container.servlet.WebComponent.service (webcomponent.java:416)
Com.sun.jersey.spi.container.servlet.ServletContainer.service (servletcontainer.java:538)
Com.sun.jersey.spi.container.servlet.ServletContainer.service (servletcontainer.java:716)
Javax.servlet.http.HttpServlet.service (httpservlet.java:723)
Org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal (characterencodingfilter.java:88)
Org.springframework.web.filter.OncePerRequestFilter.doFilter (onceperrequestfilter.java:106)


Note the "Full stack" trace of the root cause is available in the Apache tomcat/6.0.41 logs.

In the view of exceptions, this is due to a MongoDB connection timeout. So, to MongoDB to find the reason. First on the MongoDB configuration file:

Copy Code code as follows:

mongodb.replica-set=192.98.12.242:30007,192.98.12.245:30007
mongodb.hostname=192.98.12.245
mongodb.port=30007
mongodb.connections-per-host=1000
mongodb.threads-allowed-to-block-for-connection-multiplier=200
mongodb.connect-timeout=2000
mongodb.max-wait-time=2000
Mongodb.auto-connect-retry=true
Mongodb.socket-keep-alive=true
mongodb.socket-timeout=1500
Mongodb.slave-ok=true
Mongodb.write-number=1
mongodb.write-timeout=1000
Mongodb.write-fsync=true
Mongodb.dbname=shardvectordb
Mongodb.dbuser=
mongodb.dbpassword=

The connection time is 2 seconds. Then locate the MongoDB query and the result is 6, 7 seconds. It turns out that's the reason. Then locate, why does a query take so long?

After the investigation, the original query field did not create an index. Then the index is created, query dozens of milliseconds, OK problem all resolved.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.