3
votes

From What can be done in a transaction (highlight from me):

All Datastore operations in a transaction must operate on entities in the same entity group if the transaction is a single group transaction, or on entities in a maximum of twenty-five entity groups if the transaction is a cross-group (XG) transaction.

Is there an actual definition corresponding to that 25 number that I can reference in my python app code? Or an API call returning it? I'd prefer to use one, if available, rather than create my own definition of it, just in case Google decides to change it down the road...

Update: To clarify, I'm talking about the equivalent of _MAX_EG_PER_TXN which I just spotted in LiveTxn._GetTracker() from the SDK's google/appengine/datastore/datastore_stub_util.py file:

      if self._allow_multiple_eg:
        Check(len(self._entity_groups) < _MAX_EG_PER_TXN,
              'operating on too many entity groups in a single transaction.')

As a side note it'd be great for debugging if the tracked groups info from self._entity_groups could be somehow accessed when such exceptions are raised.

1
Wow 25 entity groups. It used to be only 5, well that was once they added XG transactions ;-)Tim Hoffman

1 Answers

3
votes

Entity-Groups are the top level entities (no parent/ancestor). Every child entity that references it as a ancestor falls into the same Entity-Group.

There is not a programmatic way to ask the API to get a count, but you should be able to determine it in your own code either through explicit design:

  • No more than 25 entities in a transaction if using top-level entities
  • No more than 25 distinct parents if using child entities

The definition of Entity-Groups is baked into the underlying Megastore storage layer and so is unlikely change in any way other than us increasing the limit or removing the limit.

EDIT: FR logged: https://github.com/GoogleCloudPlatform/google-cloud-datastore/issues/121