google-app-enginegoogle-cloud-datastoreentity-group-transactions

GAE datastore transaction with multiple ancestors entity groups


It is not clear for me, from the documentation, which ancestor is a boundary for a transaction. The closest one, or the root one?

I have a root entity (A) and it has a few descendants (B1, B2 ... Bn) and those can have many ancestors (C1, C2...). I will make transactions on the C entities (Cs), which I will get with an ancestor query based on a B entity. Question is, will a change in Cs under B1 throw a ConcurrentModificationException if another transaction changes some Cs under a B2 in the same time?

Do all the Cs belong to the same entity group under their grandparent A or are the entity groups also divided in smaller "sub - entity groups" i.e. every group of Cs under a B has their own entity group?


Solution

  • The boundary is the root.

    From https://developers.google.com/appengine/docs/python/datastore/transactions:

    All Datastore operations in a transaction must operate on entities in the same entity group

    and

    each root entity belongs to a separate entity group, so a single transaction cannot create or operate on more than one root entity

    So everything under A is one entity group.