Let me try and describe the requirement.
My product has many sites, each sites have many warehouses, and each warehouse has a count of a important resource it is responsible for.
Whenever someone wants that resource, I want to efficiently pick a (site, warehouse) which will fulfill the requirement (based on some heuristics.)
I reckon I need a transaction over such a operation (as I do not want to leave things in a messy state.)
I have gone over the documentation many times and understand that entity groups are the recommended way of doing transactions.
From Google AppEngine Go documentation:
An entity's parent, parent's parent, and so on recursively, are its ancestors; its children, children's children, and so on, are its descendants. An entity and its descendants are said to belong to the same entity group.
If I make it so that each warehouse has a site as an ancestor, I can get good control when operating on warehouses under the same site (i.e. entity group.)
What is the simple approach of making the operation safe across all sites and their warehouses?
Approaches I have thought of:
Is it just me or the meaning of entity group slightly up for interpretation as per the docs?
PS: The number of such safe operations required is relatively low, so I am not too worried about the limited write throughput of having things under one entity group.
The answer to your question is yes, entities belong to the same group if they have the same parent, even if that parent is a grand-parent for one or both of these entities:
Every entity with a given root entity as an ancestor is in the same entity group.
From: Transactions