- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
伙计们——我收到以下异常,无法解释原因。要保留的对象数量通常很少(<10),但是当我从 persistencemanager 使用 makepersistentall 时,我会间歇性地收到 DeadlineExceededException。
在调用 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 是否允许?它应该)。
关于java - 为什么从 App Engine 数据存储中获取 MakePersistentAll 中的 DeadlineExceededException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4027019/
伙计们——我收到以下异常,无法解释原因。要保留的对象数量通常很少( interested = getInterestedUsers(locx, locy, gamecode); // this al
我有一个迷你 CRM 应用程序。我正在尝试添加功能以允许批量用户导入。上传处理程序从 CSV 文件中读取数据,然后调用我的 CustomerService 类将 Customer 对象存储在数据存储区
我是一名优秀的程序员,十分优秀!