Hey Joel,

Your question fits more on the "general discussion" side of the sometimes* 
ambiguous boundary where it might be too in-depth for Stack Overflow, with 
too many possible answers, and yet is also a sort-of-specific issue which 
tends to get redirected to Stack. In the spirit of helping you out 
regardless, I'll be happy to assist here with some advice.

Cache invalidation is traditionally held up as a class of problem in 
computing which is devilishly hard to get right. The cardinal sin is to 
have the system perceive stale data as fresh, although it's acceptable to 
fetch stale data as long as it's identifiable as such and the path to fresh 
data is relatively cheap. 

The race condition you describe is definitely something to avoid, and I see 
one possible solution:

The deletion of the memcache key by instance 1 is clearly meant to prepare 
the way for a put() to the datastore of the new entity, so we should make 
the composition of these two actions into one atomic action, so that 
instance 2 will fail to fetch from memcache and thereafter find the new 
value in datastore. This can be accomplished as follows:

Rather than deleting the memcache key before put, a timestamp can be put in 
its place (or somehow associated with it), only to be deleted once the 
datastore entity is safely put. This means that instance 2, attempting to 
access the memcache key, would notice that it's currently being updated and 
do extremely small incremental sleeps until it finds the new version 
available in the datastore.

Could you go into a little more detail about your system specifically? I 
feel this will help spur more concrete discussion of the trade-offs you can 
make in your specific situation.

Regards,

Nick
Cloud Platform Community Support



On Thursday, March 17, 2016 at 1:27:46 PM UTC-4, Joel Holveck wrote:
>
> By the way, feel free to say this should be on Stack Overflow if that's 
> more appropriate.  I still don't have a good feel for what should be posted 
> here vs. elsewhere.
>

-- 
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 google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/54d3c351-83d7-481d-a46d-0d3225a447ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to