Reading through the source code of google_appengine module... It looks like when you do a allocate_id_range(model, start, end) the start value isn't actually sent in an RPC call. Instead it asks the datastore for the highest safe 'start' value for a given 'end'.
This suggests that the calls aren't actually 'allocating' any ids, merely telling you if the ids are safe to use. And the collision detection is just a query for existing entities (with the same parent) with keys in the given range. The docs say scary things like "IDs allocated in this manner will not be used by the datastore's automatic ID sequence generator and may be used in Keys without conflict," which suggests the generator might pick keys you've used if you don't allocate them first. ...but from what I've seen it looks like if you successfully save an entity with a particular id, the datastore's automatic ID generator will never use it. Can anyone confirm or refute? On Sep 5, 5:25 pm, Paul G <[email protected]> wrote: > The docs for allocated_id_range() just say that: > > "Returns one of (KEY_RANGE_EMPTY, KEY_RANGE_CONTENTION, > KEY_RANGE_COLLISION). If not KEY_RANGE_EMPTY, this represents a > potential issue with using the allocated key range." > > I find that this returns KEY_RANGE_CONTENTION for ranges of ids where > there are no (and as far I'm aware never have been) objects with those > id values. (In my case I also get KEY_RANGE_CONTENTION when I request > ids that do exist, so I can't imagine when an actual collision > occurs?) > > Ok that's fine but the docs don't say whether the ids have been > allocated or not... I don't mind contention if this means that App > Engine will never auto-allocate the ids in question. If contention > means GAE is planning to allocate those ids in future that's bad for > me. > > My situation is migrating data, changing the kind name of a bunch of > entities. I need to keep the ids the same. Everything was fine until I > read those docs and now I'm worried I'm setting myself up for future > id collisions unless I can tell GAE not to use my legacy ids somehow. -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
