主頁(yè) > 知識(shí)庫(kù) > MongoDB查詢字段沒(méi)有創(chuàng)建索引導(dǎo)致的連接超時(shí)異常解案例分享

MongoDB查詢字段沒(méi)有創(chuàng)建索引導(dǎo)致的連接超時(shí)異常解案例分享

熱門標(biāo)簽:智能電銷機(jī)器人銷售話術(shù) 南京400電話怎樣辦理 福州電銷機(jī)器人源代碼 企業(yè)智能外呼系統(tǒng)價(jià)格多少 高德地圖標(biāo)注商戶位置 沈陽(yáng)營(yíng)銷電銷機(jī)器人招商 徐州ai電銷機(jī)器人原理 兗州電話外呼營(yíng)銷系統(tǒng) 機(jī)器人外呼系統(tǒng)軟件存在問(wèn)題

今天在現(xiàn)場(chǎng)的哥們發(fā)來(lái)異常,讓我解決,錯(cuò)誤信息如下:

復(fù)制代碼 代碼如下:

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 wpdb
 
--------------------------------------------------------------------------------
 
type Exception report
 
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 wpdb
 
description The server encountered an internal error that 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 wpdb
    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.$Proxy50.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.$Proxy50.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.$Proxy50.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.

由異常來(lái)看,是由于MongoDB連接超時(shí)造成的。于是,往MongoDB上找原因。首先上MongoDB的配置文件:

復(fù)制代碼 代碼如下:

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=

連接時(shí)間2秒。然后在定位mongodb的查詢,結(jié)果為6、7秒。原來(lái)是這個(gè)原因。然后定位,一個(gè)查詢?yōu)槭裁春臅r(shí)那么久呢?

經(jīng)過(guò)排查,原來(lái)是查詢字段沒(méi)有創(chuàng)建索引。然后把索引創(chuàng)建,查詢幾十毫秒,ok問(wèn)題全部解決。

您可能感興趣的文章:
  • MongoDB索引使用詳解
  • MongoDB中唯一索引(Unique)的那些事
  • MongoDB的基礎(chǔ)查詢和索引操作方法總結(jié)
  • MongoDB中創(chuàng)建索引需要注意的事項(xiàng)
  • MongoDB性能篇之創(chuàng)建索引,組合索引,唯一索引,刪除索引和explain執(zhí)行計(jì)劃
  • 深入理解MongoDB的復(fù)合索引
  • mongodb處理中文索引與查找字符串詳解
  • 關(guān)于MongoDB索引管理-索引的創(chuàng)建、查看、刪除操作詳解
  • MongoDB自動(dòng)刪除過(guò)期數(shù)據(jù)的方法(TTL索引)
  • 關(guān)于對(duì)MongoDB索引的一些簡(jiǎn)單理解

標(biāo)簽:大理 本溪 景德鎮(zhèn) 丹東 吉安 鶴崗 邯鄲 昭通

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《MongoDB查詢字段沒(méi)有創(chuàng)建索引導(dǎo)致的連接超時(shí)異常解案例分享》,本文關(guān)鍵詞  MongoDB,查詢,字段,沒(méi)有,創(chuàng)建,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《MongoDB查詢字段沒(méi)有創(chuàng)建索引導(dǎo)致的連接超時(shí)異常解案例分享》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于MongoDB查詢字段沒(méi)有創(chuàng)建索引導(dǎo)致的連接超時(shí)異常解案例分享的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章