This is a weird one.

I have a cron that rolls up some data every few minutes.  Nothing too 
complicated:

class CollectStatsHandler(webapp.RequestHandler):
  def get(self):
    nodes = NodeModel.gql("WHERE online = :1 and procs > :2", True, 
0).fetch(1000)
    sum = 0
    for n in nodes:
      sum = sum + n.procs
    now = datetime.datetime.now().timetuple()
    hour = datetime.datetime(now[0], now[1], now[2], now[3])
    hourly = HourlyStatsModel.gql("WHERE hour = :1", hour).get()
    if not hourly:
      hourly = HourlyStatsModel()
      hourly.hour = hour
      hourly.stats = str(sum)
    else:
      hourly.stats = hourly.stats + "," + str(sum)
    hourly.put()    

I'm running on M/S, so every now and then I'll get timeouts or whatever, but 
that's OK because this is really just for my internal "app health" dashboard.

Anyway, yesterday I got this exception:

google.appengine.api.datastore_errors.TransactionFailedError@/base/python_runtime/python_lib/versions/1/google/appengine/datastore/datastore_rpc.py:1074
 (at least 2 occurrences)

Handler:        main.py
URL:    http://mesonstreaming.appspot.com/admin/collectStats
Stacktrace:     
Traceback (most recent call last):
  File 
"/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py",
 line 700, in __call__
    handler.get(*groups)
  File "/base/data/home/apps/mesonstreaming/51.352130110004909428/main.py", 
line 1677, in get
    hourly.put()
  File 
"/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/__init__.py",
 line 1006, in put
    return datastore.Put(self._entity, config=config)
  File 
"/base/python_runtime/python_lib/versions/1/google/appengine/api/datastore.py", 
line 467, in Put
    return PutAsync(entities, **kwargs).get_result()
  File 
"/base/python_runtime/python_lib/versions/1/google/appengine/datastore/datastore_rpc.py",
 line 658, in get_result
    results = self.__rpcs[0].get_result()
  File 
"/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py",
 line 592, in get_result
    return self.__get_result_hook(self)
  File 
"/base/python_runtime/python_lib/versions/1/google/appengine/datastore/datastore_rpc.py",
 line 1385, in __put_hook
    self.check_rpc_success(rpc)
  File 
"/base/python_runtime/python_lib/versions/1/google/appengine/datastore/datastore_rpc.py",
 line 1074, in check_rpc_success
    raise _ToDatastoreError(err)
TransactionFailedError: too much contention on these datastore entities. please 
try again.

So we have a transaction failed error on a put which is NOT a transaction.

And we have too much contention on an entity which is written once every 5 
minutes by a cron.

Huh?

-Joshua

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to