why is my appengine IdGeneratorStrategy generating huge numbers?

64 Views Asked by At

I just moved my code from one machine to another, released it and suddenly it created an entry with a key of "576728208506880" so I re-released the exact same code from the original machine and created another field and this time the key created was "21134006"

Can anyone shed any light on why this might be?!

Thanks, J

2

There are 2 best solutions below

1
On BEST ANSWER

It's perfectly normal. App Engine generates numeric IDs between 0 and 2^53, and scatters them out throughout the entire range:

http://googlecloudplatform.blogspot.ca/2013/05/update-on-datastore-auto-ids.html

You can hack around it a bit by using the legacy auto id policy in your settings.

1
On

Appengine datastore IDs are not generated sequentially.

(Imagine that you had a burst of 1,000 new entities created in the same second - the short answer is that AppEngine needs a strategy to generate IDs that won't collide).

See this answer for more details and a potential solution.

See "Assigning Identifiers" of the AppEngine docs for more information.