Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The get is not really "transactional"; if a transaction only contains reads, then committing the transaction doesn't actually do anything. Executing a read in a transaction guarantees just one thing: if the value the read returned is not the most current value any more at the time that any <em>writes</em> in the transaction are applied, the transaction will abort and none of the writes will have happened.</p> <p>So, the following sequence of events is allowed to happen:</p> <ol> <li>Start transaction 1.</li> <li>Inside transaction 1, you read entity A and it returns state A1.</li> <li>Inside transaction 1, you update entity A from state A1 to state A2.</li> <li>When committing transaction 1, it fails with one of the mentioned exceptions.</li> <li>Start transaction 2.</li> <li>Inside transaction 2, you read entity A and it returns state A1.</li> <li>Transaction 1 is applied to the datastore in the background, changing A from state A1 to state A2.</li> <li>End transaction 2 (no commit, as there were no writes).</li> </ol> <p>But, this sequence of events is different:</p> <ol> <li>Start transaction 1.</li> <li>Inside transaction 1, you read entity A and it returns state A1.</li> <li>Inside transaction 1, you update entity A from state A1 to state A2.</li> <li>When committing transaction 1, it fails with one of the mentioned exceptions.</li> <li>Start transaction 2.</li> <li>Inside transaction 2, you read entity A and it returns state A1.</li> <li>Inside transaction 2, you update entity A from state A1 to state A3.</li> <li>Transaction 1 is applied to the datastore in the background, changing A from state A1 to state A2.</li> <li>Transaction 2 now <strong>will not commit successfully</strong>, because the write it's about to apply is based on an outdated version of entity A. It will fail and A will be left in state A2.</li> </ol> <p>So, with your step 4 added to the question, you are in the second sequence of events here. It's possible that the get in step 3 returns None even though the entity does exist, but it's <em>not</em> possible for the subsequent write to succeed in that case: the transaction is out of date and thus cannot commit. The transaction will be retried, and the second time around, the get will return the object written in step 1, which is what you wanted.</p> <p>So the very short answer is: yes, it <em>can</em> return a stale value, but it's guaranteed that if the result was stale, a subsequent write to that entity in the same transaction will fail, so this should not actually cause a problem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload