My app generates a unique id string for each user who registers (like a tinyurl). The id is based on random numbers, which are seeded from a hash of their user information. There are over 240 million combinations possible for the id, but I want to avoid collision by checking against the datastore first to make sure a user with this id doesn't already exist.
While it's unlikely to happen, I see a potential race condition if 2 users register at almost the same time, and their user information hashes the same id. It's possible that both could check the datastore for id uniqueness before either has inserted the new record, and as such I could end up with two users in the datastore with the same id. Unlikely, but possible. Could I resolve this with a transaction, by making the lookup and subsequent insert a single transaction? Or would this not really resolve the issue, as a transaction's view of the datastore is frozen at the start of the transaction (so I wouldn't see the other record just inserted). If a transaction isn't the way to go, can you recommend a method to get out of this race condition? Thanks, Dave --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---