A quick update. This question has been answered on Stackoverflow here http://stackoverflow.com/questions/30233093/app-engine-mechanics-of-creating-a-unique-entity-if-it-doesnt-exist
I will summarise the answer here, if some curious soul is browsing google-groups. The explanation was provided by Jamie Gomez, and confirmed by Ryan Barrett. In the scenario described previously. 1: When the first Get(...) returns there is no entity, and therefore no timestamp for the transaction, but a new timestamp is generated at this point. 2: The Put(...) does not check or generate a timestamp. 3: When the transaction concludes the generated timestamp is tested against the timestamp in the datastore. If this transaction is the first, then there is no timestamp in the datastore and the transaction succeeds. If this transaction is the second then there will be a timestamp for the other transaction and this one will fail. It was very interesting the learn that timestamps are created for unsuccessful Get(...) calls. That was fun :) If what I have written above is inaccurate or flat out wrong I would love to hear about that. Thanks. Francis On Sunday, 17 May 2015 14:26:33 UTC+1, Dan Dubois wrote: > > Hi Francis, > > I think I understand exactly what you mean and it's an interesting edge > case when designing the datastore transaction system. > > Somehow within a transaction it needs to record that the 'put' method > either expects the entity it is saving to already exist or not exists. > What's more this logic needs to kick in only if earlier in the transaction > a 'get' bothered to detect if the entity existed in the first place! > > I hope the designers of the datastore considered this and am sure they > have as I have not seen anything to suggest transactional integrity has > ever been broken in my apps. I guess you are looking for confirmation > though as the way the datastore's internals are described in various don't > suggest the edge case is catered for. > > Maybe you could write a test and run it a reasonable number of times to > see if atomicity guarantees break. I would be interested in seeing the > results. > > Dan -- 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 post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-appengine. To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/5f74f6d4-f688-4a2d-bf90-701edf91a0cb%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
