为什么数据存储区在获取URL时会产生超时?

时间:2016-11-27 15:43:57

标签: java google-app-engine google-cloud-datastore app-engine-flexible

今天短时间内,使用Google Cloud Datastore API在灵活环境中“运行”的代码经历了 java.net.SocketTimeoutException:在将项目插入另一个GAE中的数据存储区时获取URL 时超时项目

此外,Dataflow当时未能插入项目;几乎肯定是同样的问题。

这也发生在简单的密钥查询上,因此不存在繁重数据的问题。

在此之前和之后,许多其他数据确实被正确插入;包括重新运行这些相同的数据。

Google搜索错误表明它可能是由Google Cloud中的停机时间引起的,但Google Cloud Status Dashboard显示为绿色。

是什么造成的?我们怎么能在将来避免它?

com.freightos.backup.datastore.gcloudapi.GCloudApiDSBackup$CopyEntities run: ERROR in CopyEntities(commerceDocs/RFQ) java.lang.RuntimeException: com.google.cloud.datastore.DatastoreException: I/O error at 
com.freightos.backup.datastore.gcloudapi.GCloudApiDSBackup$CopyEntities.retryIfAllowed(GCloudApiDSBackup.java:963) at 
com.freightos.backup.datastore.gcloudapi.GCloudApiDSBackup$CopyEntities.putEntities(GCloudApiDSBackup.java:857) at 
com.freightos.backup.datastore.gcloudapi.GCloudApiDSBackup$CopyEntities.retryIfAllowed(GCloudApiDSBackup.java:959) at 
com.freightos.backup.datastore.gcloudapi.GCloudApiDSBackup$CopyEntities.putEntities(GCloudApiDSBackup.java:857) at 
com.freightos.backup.datastore.gcloudapi.GCloudApiDSBackup$CopyEntities.putEntitiesByParts(GCloudApiDSBackup.java:991) at 
com.freightos.backup.datastore.gcloudapi.GCloudApiDSBackup$CopyEntities.run(GCloudApiDSBackup.java:801) at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at 
java.util.concurrent.FutureTask.run(FutureTask.java:266) at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at 
java.lang.Thread.run(Thread.java:745) Caused by: com.google.cloud.datastore.DatastoreException: I/O error at 
com.google.cloud.datastore.spi.DefaultDatastoreRpc.translate(DefaultDatastoreRpc.java:105) at 
com.google.cloud.datastore.spi.DefaultDatastoreRpc.commit(DefaultDatastoreRpc.java:133) at 
com.google.cloud.datastore.DatastoreImpl$4.call(DatastoreImpl.java:390) at 
com.google.cloud.datastore.DatastoreImpl$4.call(DatastoreImpl.java:387) at 
com.google.cloud.RetryHelper.doRetry(RetryHelper.java:179) at 
com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:244) at 
com.google.cloud.datastore.DatastoreImpl.commit(DatastoreImpl.java:386) at 
com.google.cloud.datastore.DatastoreImpl.commitMutation(DatastoreImpl.java:380) at 
com.google.cloud.datastore.DatastoreImpl.put(DatastoreImpl.java:340) at 
com.freightos.backup.datastore.gcloudapi.GCloudApiDSBackup$CopyEntities.putEntities(GCloudApiDSBackup.java:836) ... 9 more Caused by: com.google.datastore.v1.client.DatastoreException: I/O error, code=UNAVAILABLE at 
com.google.datastore.v1.client.RemoteRpc.makeException(RemoteRpc.java:126) at 
com.google.datastore.v1.client.RemoteRpc.call(RemoteRpc.java:95) at 
com.google.datastore.v1.client.Datastore.commit(Datastore.java:84) at 
com.google.cloud.datastore.spi.DefaultDatastoreRpc.commit(DefaultDatastoreRpc.java:131) ... 17 more Caused by: java.net.SocketTimeoutException: Timeout while fetching URL: https://datastore.googleapis.com/v1/projects/freightos-prod-backup2:commit at 
com.google.appengine.api.urlfetch.URLFetchServiceImpl.convertApplicationException(URLFetchServiceImpl.java:173) at 
com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:45) at 
com.google.api.client.extensions.appengine.http.UrlFetchRequest.execute(UrlFetchRequest.java:74) at 
com.google.api.client.http.HttpRequest.execute(HttpRequest.java:981) at 
com.google.datastore.v1.client.RemoteRpc.call(RemoteRpc.java:87) ... 19 more

1 个答案:

答案 0 :(得分:2)

看起来UrlFetchTransport正在被使用。

我已提交this issue来修复google-cloud-java库。

同时,在构造NetHttpTransport对象时,您应该可以强制它使用DatastoreOptions

import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.auth.http.HttpTransportFactory;

DatastoreOptions.newBuilder()
    .setHttpTransportFactory(new HttpTransportFactory() {
      @Override
      public HttpTransport create() {
        return new NetHttpTransport();
      }
    })
    ...