I appreciate any clarifications on my situation as follows. I have an
entity group whose the root entity is called "root". When a particular
URL is requested, a new entity is added to this group as a direct
child of root. The code looks similar to this:

def insert():
  root = Root.get_by_key_name('key_name')
  child = Child(parent=root)
  child.put()

Note that the insert() function is not run in a transaction (not
called by db.run_in_transaction()).

I spawned many concurrent requests to this URL. The log shows that
there are many failed requests with either "TransactionFailedError:
too much contention on these datastore entities. please try again" or
"DeadlineExceededError". Since I'm still a bit unclear about the
internal working of the datastore, these are my explanations for what
happened. Pls correct me where I'm wrong:

1. when one child entity is being inserted, it locks the entire group.
All other concurrent requests are blocked, and their child.put()
statement exclusively is retried a number of times. Say the limit
number of retry is r.

2. If child.put() is retried r times but still doesn't go through, it
gives up and yields the "too much contention" error.

3. If child.put() does not yet reach r times of retry, but its session
already reaches the time limit t, then it fails yielding the
"DeadlineExceededError".

If my explanations are correct, isn't it true that the insert()
function is exactly equivalent to this version?:

def insert():
  root = Root.get_by_key_name('key_name')
  child = Child(parent=root)
  def txn()
    child.put()
  db.run_in_transaction(txn)

Or more generally, is it true that all API operations that write to
the datastore have exactly the same effect with transaction
(automatically retried if failed, and so on)?

Thanks for clarifications,
David.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
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