Consider the second example in "Uses for Transactions" ("update an entity with a named key, or create it if it doesn't yet exist"):
https://developers.google.com/appengine/docs/java/datastore/transactions
Now consider this scenario. A multiplayer game allows only a single match between any two players. To ensure that, a key is created using each of the player's keys. This key is used as the key of a UniqueMatch entity.
So in order to create a match, a XG transaction is created. Within this transaction:
We check if there isn't a UniqueMatch entity with that key already. If a datastore.get() call using that key does not throw EntityNotFoundException, then we know that a match between those two players already exists, so we rollback() and show an error message to the players.
We put() all entities we need to put in order to create a match. This includes the UniqueMatch entity, plus some other few entities.
The transaction is then committed.
This seems to work fine. However, I noticed I can create two matches between any two players within a short time window. For a small period of time (up to 10-20s in one of the tests, actually), my calls to datastore.get(key) throw EntityNotFoundException even though that key has already been put().
This seems to be eventual consistency. But aren't entity retrivals by key guaranteed to be strongly consistent? Is this guarantee affected by the fact that this is done within a XG transaction?
Thanks in advance,