简体   繁体   中英

Google Appengine Datastore Timeout Exception

We are fetching the list of namespaces from datastore which counts upto 30k.

The cron to fetch namespaces runs daily. But one day it works fine and other day it throws datastore timeout exception.

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

Related Code :

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());
   }
}

What could be the issue?

According to official documentation:

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.

This means that datastore having troubles with your request. Try to handle that error like:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM