1

The most recent release of the GAE states the following changes:

Datastore

Cross Group (XG) Transactions: For those who need transactional writes to entities in multiple entity groups (and that's everyone, right?), XG Transactions are just the thing. This feature uses two phase commit to make cross group writes atomic just like single group writes.

I think I could use this change within the code of a project I created a while ago but I would like further information regarding this update to the App Engine. I can't seem to find any additional information. So...

How has coding transactions changed, in regards to this update? In layman's terms, how can I implement a cross-group transaction and are there still some limitations to data store transactions that I need to be aware of?

I know this is a rather vague question. My problem is that this sounds very useful, but I'm not sure how to correctly (and effectively) use this change.

Dan McGrath
  • 41,220
  • 11
  • 99
  • 130
RLH
  • 15,230
  • 22
  • 98
  • 182

1 Answers1

4

Have you read any of the docs? It sounds like you haven't (based on you saying "I can't seem to find any additional information"). In that case, check out the links below and see if still have any questions.

Conceptually, doing a cross group transaction is pretty similar to a typical GAE transaction, just slower, and only available in the HRD. Note that in general, GAE transactions, both "normal" and XG have different isolation characteristics than what you may be used to coming from a SQL database. The second link discusses this immediately after the XG section.

Here is an excerpt from the first link showing how simple using XG can be.

from google.appengine.ext import db

xg_on = db.create_transaction_options(xg=True)

def my_txn():
    x = MyModel(a=3)
    x.put()
    y = MyModel(a=7)
    y.put()

db.run_in_transaction_options(xg_on, my_txn)
Peter Recore
  • 14,037
  • 4
  • 42
  • 62
  • Yes, I understand that my comments were a bit vague, but this is exactly what was looking for. I understand now. – RLH Oct 31 '11 at 19:33