乡亲-我收到以下异常,无法解释原因。持久化对象的数量通常很小(
在makepersistentall调用之前,http请求代码还会处理对数据存储区的其他查询。查看异常跟踪,看起来有一些与等待对象相关的东西。
问题是什么,我该如何解决此异常?谢谢
====
相关代码是
// handle the updates
List<InterestQueueItem> interested = getInterestedUsers(locx, locy, gamecode); // this also results in a query into the datastore, which looks like it goes well
List <BingoUpdate> topersisteUpdates = new ArrayList<BingoUpdate>();
try {
for (InterestQueueItem item: interested) {
if (!item.getUID().equals(this.uid)) { // no need to update the originator of the update
BingoUpdate update = new BingoUpdate(item, screenname+" not working");
update.setContent("some content");
topersisteUpdates.add(update);
}
}
pm.makePersistentAll(topersisteUpdates); // exception thrown here
} finally {
pm.close();
}
BingoUpdate构造函数并没有做太多-只是getter和setter。
现“GetInterestedUsers”为
public static List<InterestQueueItem> getInterestedUsers(float locx, float locy, String gamecode) {
List<InterestQueueItem> retVal = new ArrayList<InterestQueueItem>();
PersistenceManager pm = PMF.get().getPersistenceManager();
Query query = pm.newQuery(InterestQueueItem.class);
try {
// reduce the potential set of interested folks
query.setFilter("gamecode == thisGameCode");
query.declareParameters("String thisGameCode");
retVal.addAll((List <InterestQueueItem>) query.execute(gamecode));
return retVal;
} finally {
pm.close();
}
}
异常如下:
Uncaught exception from servlet
com.google.apphosting.api.DeadlineExceededException: This request (61c89aa7e7f35f42) started at 2010/10/26 03:56:13.421 UTC and was still executing at 2010/10/26 03:56:42.750 UTC.
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:502)
at com.google.apphosting.runtime.AsyncFuture.get(AsyncFuture.java:54)
at com.google.apphosting.runtime.ApiProxyImpl$AsyncApiFuture.get(ApiProxyImpl.java:412)
at com.google.apphosting.runtime.ApiProxyImpl$AsyncApiFuture.get(ApiProxyImpl.java:244)
at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:42)
at com.google.appengine.api.datastore.FutureHelper$CumulativeAggregateFuture.get(FutureHelper.java:136)
at com.google.appengine.api.datastore.FutureHelper.getInternal(FutureHelper.java:71)
at com.google.appengine.api.datastore.FutureHelper.quietGet(FutureHelper.java:32)
at com.google.appengine.api.datastore.DatastoreServiceImpl$2.runInternal(DatastoreServiceImpl.java:115)
at com.google.appengine.api.datastore.DatastoreServiceImpl$2.runInternal(DatastoreServiceImpl.java:112)
at com.google.appengine.api.datastore.TransactionRunner.runInTransaction(TransactionRunner.java:31)
at com.google.appengine.api.datastore.DatastoreServiceImpl.put(DatastoreServiceImpl.java:112)
at org.datanucleus.store.appengine.RuntimeExceptionWrappingDatastoreService.put(RuntimeExceptionWrappingDatastoreService.java:117)
at org.datanucleus.store.appengine.DatastorePersistenceHandler.put(DatastorePersistenceHandler.java:182)
at org.datanucleus.store.appengine.DatastorePersistenceHandler.put(DatastorePersistenceHandler.java:127)
at org.datanucleus.store.appengine.DatastorePersistenceHandler.insertObjects(DatastorePersistenceHandler.java:254)
at org.datanucleus.store.appengine.BatchPutManager.processBatchState(BatchPutManager.java:35)
at org.datanucleus.store.appengine.BatchManager.finish(BatchManager.java:54)
at org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManager$BatchManagerWrapper.call(DatastoreJDOPersistenceManager.java:127)
at org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManager$BatchManagerWrapper.access$200(DatastoreJDOPersistenceManager.java:121)
at org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManager.makePersistentAll(DatastoreJDOPersistenceManager.java:98)
at com.goodconcierge.UpdateQueueThread.run(UpdateQueueThread.java:112)
at com.goodconcierge.BingoServerServlet.handleLeave(BingoServerServlet.java:92)
at com.goodconcierge.BingoServerServlet.doGet(BingoServerServlet.java:24)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:693)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:97)
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:238)
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.handleRequest(JavaRuntime.java:261)
at com.google.apphosting.base.RuntimePb$EvaluationRuntime$6.handleBlockingRequest(RuntimePb.java:8486)
at com.google.apphosting.base.RuntimePb$EvaluationRuntime$6.handleBlockingRequest(RuntimePb.java:8484)
at com.google.net.rpc.impl.BlockingApplicationHandler.handleRequest(BlockingApplicationHandler.java:24)
at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:418)
at com.google.net.rpc.impl.Server$RpcTask.runInContext(Server.java:572)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:448)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:688)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:326)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:318)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:446)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)
最佳答案
您的整个HTTP请求花费了30多秒并被杀死。
尽管有例外情况指向“永久所有”调用,但这可能不是根本原因。例如,可能是getInterestedUsers花了29秒,而persist()根本没有时间去完成。您应该在代码行周围放置跟踪,以测量它们花费的时间。
如果发现根本原因确实是persist(),请确保没有不必要的级联持久性。您可能只有几个顶级对象,但是如果它们具有一对多链接,则可能加载然后持久保存数千个对象,并且不知道它。
尝试在本地计算机上运行代码,监视实际的SQL语句(我不记得AppEngine是否允许?应该这样做)。