Robert - That is one excellent troubleshooting job. I wasn't aware that any db.get() implicitly sets entity group on a transaction. Thanks!
On Fri, Apr 22, 2011 at 8:31 AM, Robert Kluin <[email protected]>wrote: > Hi Matija, > I put together a simple python handler that can demonstrate your > problem. It also shows a potential solution. What seems to be > happening is that when your transaction is not interacting with an > entity group, the transactions run on the same entity group. If you > cause an entity group to be set, the problem should disappear -- at > least it does in my testing. > > This little handler can demonstrate this. Call it with a 'limit' > of, say, 7. You'll get a ton of transaction collisions. Then call it > again (with the same limit) but with the set_group parameter set to 1. > The collisions should go away. > > In this example I'm setting the connection's entity group by > building a key, then trying to read that entity. No need for it to > exist. In Python it is possible to set the "connection's" entity > group -- not sure how to do this in Java. > > > Robert > > > > > class InsertTaskHandler(webapp.RequestHandler): > def get(self): > self.post() > > def post(self): > task_id = self.request.get('task_id', '') > limit = int(self.request.get('limit', 2)) > depth = int(self.request.get('depth', 0)) > if depth > limit: > log.debug('Task (%s) reached limit (%d, %d)', task_id, depth, limit) > return > > tasks_to_add = int(self.request.get('tasks_to_add', 2)) > set_group = self.request.get('set_group') > > def add_tasks(): > if set_group: > group = self.request.headers.get('X-AppEngine-TaskName', 'a') > db.get(db.Key.from_path('T', group)) > log.debug('Setting group: %s.', group) > > for task in range(tasks_to_add): > log.debug('Adding task %s%d.', task_id, task) > taskqueue.add(url=self.request.path, > params={'set_group': set_group, > 'limit': limit, > 'depth': depth + 1, > 'tasks_to_add': tasks_to_add, > 'task_id': '%s%d' % (task_id, task)}, > transactional=True) > > db.run_in_transaction(add_tasks) > log.debug('Task %s done.', task_id) > > > > > > > > On Thu, Apr 21, 2011 at 06:06, Matija <[email protected]> wrote: > > I want two tasks to be enqueued or none. There are some get datastore > > operations in this first task, but no put operation. These two tasks do > > their entity group datastore put operations. > > There is much more beside this, but core usage is multiple entity group > > eventual consistency. > > Matija. > > > > -- > > 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. > > > > -- > 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. > > -- 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.
