Sri
Sri

Reputation: 1

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?

Upvotes: 0

Views: 1005

Answers (1)

Yevgen
Yevgen

Reputation: 4739

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
    }

Upvotes: 1

Related Questions