gpt4 book ai didi

java - Google Appengine 数据存储区超时异常

转载 作者:行者123 更新时间:2023-12-01 09:34:16 25 4
gpt4 key购买 nike

我们正在从数据存储中获取最多 30k 的命名空间列表。

用于获取命名空间的 cron 每天都会运行。但有一天它工作正常,有一天它会抛出数据存储超时异常。

com.google.appengine.api.datastore.DatastoreTimeoutException: The datastore operation timed out, or the data was temporarily unavailable.

相关代码:

DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
FetchOptions options = FetchOptions.Builder.withChunkSize(150);
Query q = new Query(Entities.NAMESPACE_METADATA_KIND);

for (Entity e : ds.prepare(q).asIterable(options)){
// A nonzero numeric id denotes the default namespace;
// see Namespace Queries, below
if (e.getKey().getId() != 0){
continue;
}else{
namespaces.add(e.getKey().getName());
}
}

可能是什么问题?

最佳答案

根据官方文档:

DatastoreTimeoutException is thrown when a datastore operation times out. This can happen when you attempt to put, get, or delete too many entities or an entity with too many properties, or if the datastore is overloaded or having trouble.

这意味着数据存储在处理您的请求时遇到问题。尝试处理该错误,如下所示:

import com.google.appengine.api.datastore.DatastoreTimeoutException;    
try {
// Code that could result in a timeout
} catch (DatastoreTimeoutException e) {
// Display a timeout-specific error page
}

关于java - Google Appengine 数据存储区超时异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39140310/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com