Dustin,

I tried to check this on my local deployment. The way I tested was that I
started my app ( with memcache running ) and in between restarted memcached.
And then any next operation on cache results in this exception :

Caused by: java.util.concurrent.ExecutionException:
java.lang.RuntimeException: Cancelled
        at net.spy.memcached.MemcachedClient$OperationFuture.get(
MemcachedClient.java:1222)
        at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:612)
        ... 46 more
Caused by: java.lang.RuntimeException: Cancelled
        ... 48 more

This exception happens only the first time I access cache after restarting
memcached. Subsequent calls works fine. Is this the exception that we are
all talking about ? If not, how should I be handling this ?

Thanks,
Rakesh

On Tue, Mar 18, 2008 at 10:13 AM, Dustin Sallings <[EMAIL PROTECTED]> wrote:

>
> On Mar 17, 2008, at 3:03, Massimo Marazza wrote:
>
> Thank you very much for your reply. Do you think you will make a fix?
>
>
> Unfortunately, I don't see how it's possible for this bug to actually
> happen on a working JVM.  Assuming we're all talking about the same bug:
>
> http://code.google.com/p/spymemcached/issues/detail?id=10
>
> The log is showing an unhandled exception coming out of a try block that
> catches Exception (and I've confirmed that the exception descends from
> java.lang.Exception).  I can't catch it anymore than I already am, so I
> may need a bit more help in reproduction.
>
> In particular, I haven't been able to run anything under windows (I've got
> a VM with XP, but I don't have any idea how to use it).
>
> I've tried this workaround in the singleton that creates the
> MemcachedClient object
>
> public synchronized static MemcachedClient getIstance(String hostcache)
> throws Exception{
> if (memcachedClient == null) {
>   try { memcachedClient = new MemcachedClient(AddrUtil.getAddresses
> (hostcache));
>   } catch(Exception e) { e.printStackTrace(); }
>   }else{
>     if (!memcachedClient.isAlive()){
>       try { memcachedClient = new MemcachedClient(AddrUtil.getAddresses
> (hostcache));
>     } catch(Exception e) {e.printStackTrace();}
>   }
>   return memcachedClient;
> }
> }
>
> If the memcached server is down, when I try to get a MemcachedClient
> object for the first time, a new MemcachedClient object is created.
> Next times, when I try to get an istance, the MemcachedClient is alive so
> the thread is running trying to connect to memcached server. When the
> memcached server
> goes up, the thread connects to server.
> Do you think it could be a good workaround?
>
>
> It may be.  I can't guarantee it'll clean up resources since there's not a
> proper shutdown sequence there.  It also swallows errors in two places.  If
> you just took out the try and catch blocks, it'd be safer.
>
> --
> Dustin Sallings
>
>

Reply via email to