Salutations Kartik,

Contention happens when you are doing to many writes per second. This is a 
great article on avoiding it. 
<https://cloud.google.com/appengine/articles/scaling/contention?hl=en> If 
you give some more details as to what you are doing I might be able to give 
some more specific advice.

On Thursday, August 4, 2011 at 9:48:37 AM UTC-4, Joshua Smith wrote:
>
> 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.pyURL:
> http://mesonstreaming.appspot.com/admin/collectStatsStacktrace:
>
> 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 unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/9e5c32f0-8d99-4d6a-b56e-1c6dba9e25c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to