Certainly Ikai,

Firstly, some of my logs (url and classes slightly modified to hide
some app details) that show how only the same instance picks up the
entry. I'm determining and logging the instance using a UUID that I
assign to a static class variable. The key for the cache lookup is
passed in as a request query parameter to the followup requests.

Here are two runs of the code to follow. In each, the bottom log is
the cache entry being added. The next two are subsequent requests that
both look for the entry. The entry is only found when then instance
matches, regardless of which follow-up request.

This first run shows how the bottom instance is different from the one
that services both followup requests. So they don't find the entry:

50.16.21.20 - - [16/Dec/2010:11:19:40 -0800] "GET /processg?key=619001
W 12-16 11:19AM 40.373 com.mycode.CallProcessGatherServlet doGet:
LOOKING IN CACHE on Instance: b7c866f2-d74b-45df-9993-1d2c4705d3d1
W 12-16 11:19AM 40.373 com.mycode.CallProcessGatherServlet doGet:
Message NOT found in cache for 619001 - building

50.16.21.20 - - [16/Dec/2010:11:19:35 -0800] "POST /startreminder?
key=619001&pname=Optimal+Physio+Dev&atime=Friday+December+17%2C
+2%3A18+PM&rlang=en&rvoice=woman
W 12-16 11:19AM 33.173 com.mycode.CallMLServlet doGet: LOOKING IN
CACHE on Instance: b7c866f2-d74b-45df-9993-1d2c4705d3d1
W 12-16 11:19AM 33.173 com.mycode.CallMLServlet doGet: Message NOT
found in cache for 619001 - building

0.1.0.2 - - [16/Dec/2010:11:19:08 -0800] "POST /tasks/voicereminder
HTTP/1.1" 200 105 "http://cliniconexdev.appspot.com/cron/
processreminders?state=new"
W 12-16 11:19AM 08.581 com.mycode.CallPhoneAdapter doSend: CACHING
message from instance: e4d5452e-c744-4333-b1d4-38eb55f97445
W 12-16 11:19AM 08.585 com.mycode.CallPhoneAdapter doSend: Adding to
cache with key:619001
W 12-16 11:19AM 08.604 com.mycode.CallPhoneAdapter doSend:
Successfully cached reminder 619001

In this second run, the first followup request hits the same instance
that added it, and finds it. The second isn't so lucky, hitting a
different instance

184.73.13.122 - - [16/Dec/2010:11:22:39 -0800] "GET /processg?
key=620001
W 12-16 11:22AM 38.782 com.mycode.CallProcessGatherServlet doGet:
LOOKING IN CACHE on Instance: ff6ef71c-a017-4316-aa81-e77db741702b
W 12-16 11:22AM 38.782 com.mycode.CallProcessGatherServlet doGet:
Message NOT found in cache for 620001 - building

204.236.222.67 - - [16/Dec/2010:11:22:28 -0800] "POST /startreminder?
key=620001&pname=Optimal+Physio+Dev&atime=Friday+December+17%2C
+2%3A18+PM&rlang=en&rvoice=woman HTTP/1.1" 200 683 -
"CallProxy/0.7,gzip(gfe)" "cliniconexdev.appspot.com" ms=24 cpu_ms=23
api_cpu_ms=0 cpm_usd=0.000805
W 12-16 11:22AM 28.127 com.mycode.CallMLServlet doGet: LOOKING IN
CACHE on Instance: b7c866f2-d74b-45df-9993-1d2c4705d3d1
W 12-16 11:22AM 28.134 com.mycode.CallMLServlet doGet: Message for
entry 620001 FOUND in cache - using

0.1.0.2 - - [16/Dec/2010:11:22:06 -0800] "POST /tasks/voicereminder
HTTP/1.1" 200 105 "http://cliniconexdev.appspot.com/cron/
processreminders?state=new" "AppEngine-Google;
(+http://code.google.com/appengine)" "cliniconexdev.appspot.com"
ms=506 cpu_ms=1664 api_cpu_ms=941 cpm_usd=0.046287 queue_name=reminder-
queue task_name=17196018701084092971
W 12-16 11:22AM 05.964 com.mycode.CallPhoneAdapter doSend: CACHING
message from instance: b7c866f2-d74b-45df-9993-1d2c4705d3d1
W 12-16 11:22AM 05.965 com.mycode.CallPhoneAdapter doSend: Adding to
cache with key:620001
W 12-16 11:22AM 05.984 com.mycode.CallPhoneAdapter doSend:
Successfully cached reminder 620001

Here is the code that creates the cache (if required) and adds the
entry in the first request:
Cache cache = null;

log.warning("CACHING message from instance: " + jvmId);

try {
   cache = CacheManager.getInstance().getCache("cache_reminderVoice");
 } catch (final Exception e) {
    log.fine("Cache cache_reminderVoice not yet created");
}

if (cache == null) {
  try {
     cache = CacheManager.getInstance().getCacheFactory()
            .createCache(Collections.emptyMap());
     CacheManager.getInstance().registerCache("cache_reminderVoice",
cache);
  } catch (final CacheException e) {
        log.warning("Could not create/register cache
cache_reminderVoice: "
            + e.getMessage());
  }
}

try {
      // Put the value into the cache.
   log.warning("Adding to cache with key:" +
reminder.getKeyId().toString());
   if (parts == null) {
      log.warning("Hmmmm..parts was null");
   }
   cache.put(reminder.getKeyId().toString(), parts);

   // Get the value from the cache just to test it is there
   final CacheEntry entry = cache.getCacheEntry(reminder.getKeyId()
          .toString());
   if (entry != null) {
        log.warning("Successfully cached reminder " +
reminder.getKeyId());
   } else {
        log.warning("Could not get cached voice message parts");
    }
 } catch (final Exception e) {
      log.warning("FAILED to cache voice message parts: " +
e.getMessage());
 }

Here is the code (same in both request handlers) that retrieves the
entry from the cache:

Cache cache = null;

 log.warning("LOOKING IN CACHE on Instance: " +
TwilioPhoneAdapter.jvmId);

 try {
        cache =
CacheManager.getInstance().getCache("cache_reminderVoice");
        if (cache != null) {
          parts = (VoiceParts) cache.get(key);
        }
        if (parts != null) {
          log.warning("Message for entry " + key + " FOUND in cache -
using");
        }
 } catch (final Exception e) {
        log.warning("Cache cache_reminderVoice not yet created");
 }

 if (parts == null) {
        log.warning("Message NOT found in cache for " + key + " -
building");
        parts = ...//Builds the parts up from scratch
 }

Thanks for checking it out Ikai.
Tom

On Dec 16, 1:32 pm, "Ikai Lan (Google)" <ikai.l+gro...@google.com>
wrote:
> This is definitely not a design intent. Can you post any code or
> reproduction steps?
>
> --
> Ikai Lan
> Developer Programs Engineer, Google App Engine
> Blogger:http://googleappengine.blogspot.com
> Reddit:http://www.reddit.com/r/appengine
> Twitter:http://twitter.com/app_engine
>
> On Wed, Dec 15, 2010 at 7:42 PM, Tom Phillips <tphill0...@gmail.com> wrote:
> > I posted on this this in the java forum, but no traction there and I
> > suspect it's not java specific.
>
> > Memcache entries seem to be being scoped to an instance, not global.
> > After a cache entry is made, it can be retrieved fine for any request
> > that goes to that same instance. Any request to one of the other
> > instances never finds the entry in the cache.
>
> > Bug in Always On? Bug in 1.4.0? Design intent?
>
> > Thanks,
> > Tom
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google App Engine" group.
> > To post to this group, send email to google-appeng...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-appengine+unsubscr...@googlegroups.com<google-appengine%2bunsubscr...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-appengine?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to