Hi Andy, strange that nobody replied to this question up to now. I was wondering the same thing, until I read in the docs:
Finally, you can use a transaction to read a consistent snapshot of the > Datastore. This can be useful when multiple reads are needed to render a > page or export data that must be consistent. These kinds of transactions > are often called *read-only* transactions, since they perform no writes. > Read-only single-group transactions never fail due to concurrent > modifications, so you don't have to implement retries upon failure. > However, XG transactions can fail due to concurrent modifications, so these > should have retries. Committing and rolling back a read-only transaction > are both no-ops. (source: https://developers.google.com/appengine/docs/java/datastore/transactions) But, I still wonder how this is achieved. I thought that optimistic concurrency works like this: - when we enter a transaction a timestamp is associated to the transaction. - when we commit a transaction, the timestamp is compared with the modification timestamps of all "touched" entities in our transaction - if there are entities which have a newer timestamp than the one of the transaction, the transaction fails It seems that the Google datastore somehow achieves to freeze the datastore, so there is no conflict when another transaction modifies your data while you read it. However, if both transactions modify an entity, this is a conflict and the second transaction won't commit. My question: how is it technically achieved to look at a "freezed" version of the datastore from the point of view of a transaction? On Tuesday, January 24, 2012 4:48:18 PM UTC+1, AndyD wrote: > > Example case: > > time 0: transaction A begins > time 1: transaction B begins > time 2: transaction A reads entity 123 > time 3: transaction B writes entity 123 (or entity 456, in the same entity > group as 123) > time 4: transaction B is committed > time 5: transaction A is committed > > There are no write operations in transaction A. Does the commit of A fail > with a ConcurrentModificationException? > > -AndyD > -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/lDd_zdP7fAkJ. 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.
