5

com.google.apphosting.api.ApiProxy$ApiDeadlineExceededException: The API call memcache.Get() took too long to respond and was cancelled.

处理此类 Memcache 错误的最佳方法是什么?我假设 memcache 调用(与数据存储调用相反)如果由于某种原因失败,则只会返回 null,因为当从缓存中删除缓存项时,总是可能出现 null 结果。

我正在考虑用我自己的方法包装 memcache 调用以捕获异常并返回 null。有更好的想法吗?

编辑:我现在看到您可以设置错误处理程序。LogAndContinueErrorHandler 应该是默认值,但不清楚究竟设置/正在使用什么。这似乎是要走的路。


编辑:这是完整的堆栈跟踪:

com.google.apphosting.api.ApiProxy$ApiDeadlineExceededException: The API call memcache.Get() took too long to respond and was cancelled.
    at com.google.apphosting.runtime.ApiProxyImpl$3.createDeadlineException(ApiProxyImpl.java:318)
    at com.google.appengine.tools.development.TimedFuture.get(TimedFuture.java:44)
    at com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:63)
    at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:90)
    at com.google.appengine.api.memcache.MemcacheServiceImpl.quietGet(MemcacheServiceImpl.java:28)
    at com.google.appengine.api.memcache.MemcacheServiceImpl.get(MemcacheServiceImpl.java:51)
    at mikelike.account.Account.getPrivateBoardsFromCache(Account.java:1110)
    at org.apache.jsp.inc.dialogs.pin_005fdialog_jsp._jspService(pin_005fdialog_jsp.java:77)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at org.mortbay.jetty.servlet.Dispatcher.include(Dispatcher.java:192)
    at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
    at org.apache.jsp.inc.header_jsp._jspService(header_jsp.java:145)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at org.mortbay.jetty.servlet.Dispatcher.include(Dispatcher.java:192)
    at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
    at org.apache.jsp.index_jsp._jspService(index_jsp.java:107)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:327)
    at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:126)
    at com.google.apphosting.runtime.jetty.ResourceFileServlet.serveWelcomeFileAsForward(ResourceFileServlet.java:342)
    at com.google.apphosting.runtime.jetty.ResourceFileServlet.maybeServeWelcomeFile(ResourceFileServlet.java:281)
    at com.google.apphosting.runtime.jetty.ResourceFileServlet.doGet(ResourceFileServlet.java:142)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at mikelike.common.MikeLikeServletFilter.doFilter(MikeLikeServletFilter.java:191)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:102)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:249)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:135)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:446)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:449)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:455)
    at com.google.tracing.TraceContext.runInContext(TraceContext.java:695)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:333)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:325)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:453)
    at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
    at java.lang.Thread.run(Thread.java:679) 

编辑:这是标题:

Host: www.mikelike.com
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Referer: http://www.mikelike.com/pin/PiAILvNi4yA3c/no-description
Accept-Language: ja,en-US;q=0.8,en;q=0.6
Accept-Charset: Shift_JIS,utf-8;q=0.7,*;q=0.3
Cookie: bookmarklet=mikelike; __utma=144575401.2134744684.1335291737.1336151354.1336236818.8; __utmb=144575401.263.10.1336236818; __utmc=144575401; __utmz=144575401.1336236818.8.7.utmcsr=pinterest.com|utmccn=(referral)|utmcmd=referral|utmcct=/nagakubo/watch-later/; fbm_247980821960554=base_domain=.mikelike.com; fbsr_247980821960554=bCuJN2JJUzK9RpAzxnurnPTaWLLYIk3MAnBrjDn0_WE.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImNvZGUiOiIyLkFRQ1JJeldBYWUyY1FHUGcuMzYwMC4xMzM2MjQ4MDAwLjEtMTI1ODY2OTgzN3xLWEd4MVVNYS12T0k2RGxWaW90NVppRndWZ1kiLCJpc3N1ZWRfYXQiOjEzMzYyNDQxODMsInVzZXJfaWQiOiIxMjU4NjY5ODM3In0
X-Zoo: app-id=mikelikecom,domain=mikelike.com,host=www.mikelike.com
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19
X-Google-Apps-Metadata: domain=mikelike.com,host=www.mikelike.com
X-AppEngine-Country: JP
X-AppEngine-Region: 13
X-AppEngine-City: fuchu
X-AppEngine-CityLatLong: 35.668973,139.477661
X-AppEngine-Default-Namespace: mikelike.com

编辑:这是完整的日志条目。

2012-05-12 18:37:24.317 /ml/scripts/set_bookmarklet_cookie/?pin_service=mikelike&_=1336873018270 500 25355ms 2kb Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.55.3 (KHTML, like Gecko) Version/5.1.5 Safari/534.55.3

99.226.111.36 - - [12/May/2012:18:37:24 -0700] "GET /ml/scripts/set_bookmarklet_cookie/?pin_service=mikelike&_=1336873018270 HTTP/1.1" 500 2793 "http://pinterest.com/pin/126593439495821330/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.55.3 (KHTML, like Gecko) Version/5.1.5 Safari/534.55.3" "www.mikelike.com" ms=25356 cpu_ms=19232 api_cpu_ms=0 cpm_usd=0.635415 instance=00c61b117c5f07e0509d55c89da88f028311b8

W 2012-05-12 18:37:23.996

/ml/scripts/set_bookmarklet_cookie/
com.google.apphosting.api.ApiProxy$ApiDeadlineExceededException: The API call memcache.Get() took too long to respond and was cancelled.
    at com.google.apphosting.runtime.ApiProxyImpl$3.createDeadlineException(ApiProxyImpl.java:318)
    at com.google.appengine.tools.development.TimedFuture.get(TimedFuture.java:44)
    at com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:63)
    at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:90)
    at com.google.appengine.api.memcache.MemcacheServiceImpl.quietGet(MemcacheServiceImpl.java:28)
    at com.google.appengine.api.memcache.MemcacheServiceImpl.get(MemcacheServiceImpl.java:51)
    at mikelike.account.Account.getAccountFromCache(Account.java:1053)
    at mikelike.common.MikeLikeServletFilter.getUserAccount(MikeLikeServletFilter.java:209)
    at mikelike.common.MikeLikeServletFilter.doFilter(MikeLikeServletFilter.java:165)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:102)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:249)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:135)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:446)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:449)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:455)
    at com.google.tracing.TraceContext.runInContext(TraceContext.java:695)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:333)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:325)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:453)
    at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
    at java.lang.Thread.run(Thread.java:679)
4

1 回答 1

0

开发服务器上是否发生此错误?如果是这样,请记住,memcache 内存使用会随着时间的推移而增长(如果您没有明确清除项目..),因为内部 memcache api 在开发服务器上没有得到正确管理。

于 2012-05-04T08:34:25.853 回答