Q:

What exactly does "With a transaction, the second attempt fails atomically" mean?

I'm using GAE and I've found the documentation about how to use transactions to handle two threads attempting to create an entity with the same key. Unfortunately, the documentation isn't clear about exactly how to detect the situation. It says "the second attempt fails atomically", but how? Does it throw an exception and if so, which one?

A:

it raises ConcurrentModificationException. from your docs link, just after the first code block:

This requires a transaction because the value may be updated by another user...If the entity is updated during the transaction, then the transaction fails with a ConcurrentModificationException. The application can repeat the transaction to use the new data.

