0

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

johnvdenley
  • 739
  • 1
  • 7
  • 16

2 Answers2

2

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.

dragonx
  • 14,963
  • 27
  • 44
  • AH_HA - yes OK , so its the 1.8.1 that has caused this for me, I had not noticed that my newer PC was compiling with a newer version of the SDK! annoying though that there is no option to create a sequentially growing id number. Currently my app created a unique url for each customer based on their AdminID so the first one ever was 31014, and a more recent one was 19404014 all OK so far but to give my users an ID of 576728208506880 is a little bit crazy! so I will have to recode before releasing! I might just use a date 131204 and add an extra digit if there is a clash on creation... – johnvdenley Dec 04 '13 at 18:27
1

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.

Community
  • 1
  • 1
Josh
  • 603
  • 3
  • 16
  • I understand that, but the query is why it might create a massive number with one instance and a smaller number with a different compiled version of the same code, whenever i generate a record with the newer compile its a huge number and when I used the older compiled version its a much smaller number. I am completely happy that they are non sequential, its just that with all my previous code versions the numbers have at least been getting bigger slowly over time (which makes sense) what doesnt make sense is that it creates a big number then a small number (backwards?!) – johnvdenley Dec 04 '13 at 18:13