liu4lin / memcached-session-manager

Automatically exported from code.google.com/p/memcached-session-manager
0 stars 0 forks source link

Add support to store serialized data as a string to work around loss of type information after Couchbase failover #216

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
After a couchbase node failover, sessions that are pulled from a replica lose 
their type information.  Instead of returning a byte array, the CouchBase 
client returns a String, resulting in a ClassCastException:

Reproduction Steps
1.  On a Couchbase cluster, configure a bucket for Tomcat sessions with 
replication enabled.
2.  Populate the bucket with some sessions.
3.  Bring down the node containing your target session.
4.  Make a request to the Tomcat server with your session.

Either use a single session, and a new / empty bucket so you can tell which 
server is the primary for your session, or a load test with several session.

Expected output:
The Tomcat server restores the last known state of the session

What do you see instead?
The following exception and Stack Trace:
de.javakaffee.web.msm.MemcachedSessionService
loadFromMemcached
WARNING: Could not load session with id 2CAF3AD14FCB9B4F92A9E0684AB49D28
from memcached.
java.lang.ClassCastException: java.lang.String cannot be cast to [B
    at de.javakaffee.web.msm.LockingStrategy.loadSessionValidityInfoForValidityKey(LockingStrategy.java:333)
    at de.javakaffee.web.msm.LockingStrategy.loadSessionValidityInfo(LockingStrategy.java:328)
    at de.javakaffee.web.msm.LockingStrategy.onAfterLoadFromMemcached(LockingStrategy.java:363)
    at de.javakaffee.web.msm.MemcachedSessionService.loadFromMemcached(MemcachedSessionService.java:1106)
    at de.javakaffee.web.msm.MemcachedSessionService.findSession(MemcachedSessionService.java:585)
    at de.javakaffee.web.msm.MemcachedBackupSessionManager.findSession(MemcachedBackupSessionManager.java:216)
    at org.apache.catalina.connector.Request.doGetSession(Request.java:2913)
    at org.apache.catalina.connector.Request.getSession(Request.java:2310)
    at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:897)
    at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:229)
    at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:229)
    ...

What version of the product are you using? On what operating system?
Amazon Linux 2014.09
Tomcat 7.0.55
memcached-session-manager-1.8.1.
Couchbase Servers Version: 3.0.0 Community Edition (build-1209)
Couchbase Client: 1.4.5

Please provide any additional information below:

On testing with a standalone Java program, it looks like values that are stored 
as Strings do read back correctly after a failover.  If it was possible for the 
transcoder to use a base64 encoded string instead of a byte array, it should 
work around the problem.

Original issue reported on code.google.com by andre.va...@spritzinc.com on 4 Nov 2014 at 7:26

GoogleCodeExporter commented 9 years ago
This was caused by Couchbase bug MB-12328 
(http://www.couchbase.com/issues/browse/MB-12328)

As that issue has been fixed in version 3.0.1, working around the problem with 
a String is no longer necessary.  I think this issue can be closed.

Original comment by andre.va...@spritzinc.com on 4 Nov 2014 at 11:31

GoogleCodeExporter commented 9 years ago
Ok, closing. 

Original comment by martin.grotzke on 5 Nov 2014 at 10:12