I think I found half of an answer here:

http://bolour.com/blog/2009/06/the-google-app-engine-data-model/

Quoting:

  "GAE uses optimistic concurrency control for transactions, and its
concurrency control algorithm operates at the root level of an entity
group. The optimistic concurrency control timestamp of the root
reflects the last update time of any entity in the group. So large
entity groups increase the likelihood of timestamp conflicts and
resulting rollbacks."
  "Currently the data store cannot support more than about 10 writes
per entity group per second all told. So large entity groups reduce
parallelism between transactions since a transaction affecting any
entity in an entity group requires a write to the group’s root
entity."

This suggests that whenever a transaction is used to update a child
entity, a pseudo-lock on the entity root is used as a timestamp there
has to be written.

My question is thus: if I am not doing a put within a transaction,
will I still have to pay this price of serialized access? Can I safely
assume that I can bypass the optimistic concurrency lock by not using
transactions if I'm creating a child entity by itself?


On Jan 28, 5:11 pm, Ugorji <[email protected]> wrote:
> Thanks Enrique for your response.
>
> This seems to be what the app engine docs are alluding to, but they
> are not specific on the writes when the parent entity is not part of
> the transaction, and furthermore they suggest that optimistic
> concurrency is used and not locking, which lends credence that if the
> parent is not involved and just new entities are being created, there
> should be no contention. I've watched some of the Google IO videos
> also, and they seem to suggest that, but are not specific.
>
> http://code.google.com/appengine/docs/whatisgoogleappengine.html
>
> Looking at the link above, under the title "The Datastore", and I
> quote:
>
>   "An update of a entity occurs in a transaction that is retried a
> fixed number of times if other processes are trying to update the same
> entity simultaneously."
>
> This suggests that optimistic concurrency only applies if multiple
> processes are trying to update the *same* entity simultaneously.
> Optimistic concurrency also *implies* that first one wins.
>
> In my case, they are not trying to update the same entity, so it
> shouldn't matter.
>
> It seems the app engine docs are not clear on this, and I really want
> to leverage the entity groups in this way. Maybe one of the Google
> guys can help clarify this?
>
> On Jan 28, 4:56 pm, Enrique Perez <[email protected]> wrote:
>
>
>
> > My understanding is that all writes within the same entity group are
> > serialized. Hence a best practice is keep Entity Groups as small as
> > possible. If there is contention between two simulatanous writes to
> > the same Entity Group, one fails, and having retry logic here will
> > help get that second write to succeed .... In my experience a high
> > percentage of write retries succeed on 2nd or 3rd retry....  Hopefully
> > this helps...
>
> > Thanks
> > Enrique Perez
> > Austin, Texas
>
> > On Jan 28, 6:47 pm, Ugorji <[email protected]> wrote:
>
> > > I want to put some entities in the same entity group as a parent. If
> > > multiple users try to create child entities at the same time, will
> > > their put requests all lock on the parent entity and get executed in
> > > sequence (even though I am not making any changes to the parent? and
> > > the parent does not hold references to the children). I would hope
> > > not, but want some clarity on this.
>
> > > If their put requests get run one at a time, will I have to
> > > continually retry? I read somewhere that App Engine automatically
> > > retries non-transactional requests on failures. However, I then read
> > > here that we should retry our requests as is typical where optimistic
> > > concurrency is 
> > > used.http://code.google.com/appengine/docs/java/datastore/transactions.htm...
>
> > > What are the rules on when a retry is needed? Are they needed anytime
> > > I try to create a child entity without affecting the parent?

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" 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-java?hl=en.

Reply via email to