title: GAE HDR: Are entity retrievals by key eventually consistent within a XG transaction?
body: <p>Consider the second example in "Uses for Transactions" ("update an entity with a named key, or create it if it doesn't yet exist"):</p>
  
  <p><a href="https://developers.google.com/appengine/docs/java/datastore/transactions">https://developers.google.com/appengine/docs/java/datastore/transactions</a></p>
  
  <p>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.</p>
  
  <p>So in order to create a match, a XG transaction is created. Within this transaction:</p>
  
  <ol>
  <li><p>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.</p></li>
  <li><p>We put() all entities we need to put in order to create a match. This includes the UniqueMatch entity, plus some other few entities.</p></li>
  <li><p>The transaction is then committed.</p></li>
  </ol>
  
  <p>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().</p>
  
  <p>This seems to be eventual consistency. But aren't entity retrivals <strong>by key</strong> guaranteed to be strongly consistent? Is this guarantee affected by the fact that this is done within a XG transaction?</p>
  
  <p>Thanks in advance,</p>