Thank you Sam for the response. I am always using the AllocateIDs API as documented in the client library (not the appengine api).
https://godoc.org/cloud.google.com/go/datastore#Client.AllocateIDs Say I have two users, with Keys (User,1) and (User,2). If I do the following key1s := []*datastore.Key{datastore.IDKey('Order',0,User1key} key1s, err = client.AllocateIDs(ctx, keys1) key2s := []*datastore.Key{datastore.IDKey('Order',0,User2key} key2s, err = client.AllocateIDs(ctx, keys2) Will the id of the Order entity with User1 as parent and User2 as parent likely to get the same ID? It seems that it is possible as the uniqueness is only guaranteed within entity group. If so, I am thinking of using a top level dummy entity to generate unique keys for creating Unique IDs for Orders across users. This is as per the suggestion at https://stackoverflow.com/questions/51407626/google-cloud-datastore-unique-autogenerated-ids Is that a reasonable solution given that I never insert these dummy entities but only allocate ids? On Wednesday, May 22, 2019 at 12:40:11 PM UTC-7, Sam (Google Cloud Support) wrote: > > Hi, each System-allocated ID values are guaranteed unique to the entity > group. As our docs state here [1]: "Each entity in a Datastore mode > database has a key that uniquely identifies it." > > If you copy an entity from one entity group or namespace to another and > wish to preserve the ID part of the key, be sure to allocate the ID first > to prevent Datastore from selecting that ID for a future assignment [2]. > This might be applicable to the issue you are facing. > > Note that you can create an entity without specifying an ID, in which case > datastore automatically generates a numeric ID. If you choose to specify > some IDs and then let Cloud Datastore automatically generate some IDs, you > could violate the requirement for unique keys. Is this what's happening in > your case? To avoid this, reserve a range of numbers to use to choose IDs > or use string IDs to avoid this issue entirely as our docs suggests [3]. > > I hope this answers your question and helps you to resolve the issue. > > [1] https://cloud.google.com/datastore/docs/concepts/entities > [2] > https://cloud.google.com/datastore/docs/concepts/entities#entity_groups > [3] > https://cloud.google.com/appengine/docs/standard/python/ndb/creating-entity-keys#numeric_keys > -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/98da9dfd-44de-4ff1-8c82-89804933f952%40googlegroups.com.
