Hello Albert,

On Monday, June 10, 2013 5:06:07 AM UTC-5, Albert wrote:

> Is it ever possible for the db.get() operation at step 3 above to return 
> a stale value (or not the updated value set on step 1)? Are transactional 
> db.get() operations guaranteed to return the freshest result even if the 
> "weird" transaction exception occurs right before it?
>
>
> Short answer: Yes.

Long answer: It's complicated and depends on many factors. 

For now, let's ignore the transaction and exception details. Suppose you 
make a simple datastore put, then immediately query the datastore for that 
entity. There's a good chance that the entity that you just put in won't 
exist, because it takes time for the datastore to commit and apply the 
entity (fully write the entity, including all needed indexes, etc). The 
time to fully write an entity differs depending on how big the entity is, 
how many indexes are written, etc, but I usually ballpark it at around 
100-200 ms. As a side note, this is why sharding exists: because on a high 
traffic app, a single entity simply cannot be written to fast enough to 
handle all the incoming writes and not lose data.

Within a transaction context, the same principles apply: depending on how 
soon your db.get executes after the transaction Exception, you may get 
stale data. The key here is the Exception: it's there to warn you that the 
apply phase has been delayed for some internal reason. The apply may have 
already occurred, it may be delayed for an unknown amount of time, or it 
may not be valid anymore. So just to repeat: an Exception from a 
transaction may cause stale data.

My suggestion is to use the Exception to rerun the transaction; for 
instance if an exception comes up, you could queue up a task to redo the 
transaction.


On Monday, June 10, 2013 5:06:07 AM UTC-5, Albert wrote:

> I also asked this in 
> stackoverflow<http://stackoverflow.com/questions/16998682/is-it-possible-for-a-transactional-db-get-to-return-a-stale-result-if-a-recent>,
>  
> but I didn't get an answer.
>
I don't know about others, but I prefer to lurk within this mailing list. 
It's more convenient for me to answer questions via email than through SO.


-----------------
-Vinny P
Technology & Media Advisor
Chicago, IL

My Go side project: http://invalidmail.com/

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to