escapeCycle / memcached-session-manager

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

"removeFromMemcached" is called after tomcat failover #154

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Gist:

I am currently using this solution to scale our e-commerce application. I use 
sticky sessions and that all the calls to the server should update the session, 
even for js and images. 

Here is my config

 <Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
            memcachedNodes="n1:10.2.4.128:11211"
        sticky="true"
        sessionBackupAsync="true"
        transcoderFactoryClass="de.javakaffee.web.msm.serializer.xstream.XStreamTranscoderFactory"
       />

And that I see removedFromMemcached Called twice, where it succeeds on first 
and failed on the 2nd (Because it was deleted already.)

Environment:

2 Tomcat 6
1 Apache HTTP Server
1 Memcached (CouchBase server)

What steps will reproduce the problem?
1. Start the Tomcat 1 & 2
2. Launch the browser and sign in
3. Kill one tomcat instance.
4. The other tomcat should take responsibility of the session.

What is the expected output? What do you see instead?
I expect that the removeFromMemcached is called once.

I see 2 of them..

FINE: Found session with id 449A7CF0B4B06CA0B5B7184A1F212204-n1.node2
Dec 10, 2012 4:36:41 PM de.javakaffee.web.msm.MemcachedBackupSessionManager 
remove
FINE: remove invoked, removeFromMemcached: true, id: 
449A7CF0B4B06CA0B5B7184A1F212204-n1.node2
Dec 10, 2012 4:36:41 PM de.javakaffee.web.msm.MemcachedSessionService 
deleteFromMemcached
FINE: Deleting session from memcached: 449A7CF0B4B06CA0B5B7184A1F212204-n1.node2
Dec 10, 2012 4:36:41 PM de.javakaffee.web.msm.SessionIdFormat createSessionId
FINE: Creating new session id with orig id 'ping' and memcached id 'n1'.
Dec 10, 2012 4:36:41 PM de.javakaffee.web.msm.NodeAvailabilityCache 
updateIsNodeAvailable
FINE: CacheLoader returned node availability 'true' for node 'n1'.
Dec 10, 2012 4:36:41 PM de.javakaffee.web.msm.MemcachedSessionService 
loadFromMemcached
FINE: Loading session from memcached: 449A7CF0B4B06CA0B5B7184A1F212204-n1.node2
Dec 10, 2012 4:36:41 PM de.javakaffee.web.msm.MemcachedSessionService 
loadFromMemcached
FINE: Session 449A7CF0B4B06CA0B5B7184A1F212204-n1.node2 not found in memcached.
Dec 10, 2012 4:36:41 PM de.javakaffee.web.msm.MemcachedSessionService 
createSession
FINE: createSession invoked: null

What version of the product are you using? On what operating system?
I am using the latest release you specified in the downloads. This is my 
testing from my environment.

Tomcat 1 --> RedHat
Tomcat 2 --> ubuntu 12.04
Apache HTTP Server --> Windows 7
CouchBase --> Ubuntu 12.04

Please provide any additional information below.

This is only happening for one environment going to another.

I've assigned Redhat as my node1 and primary server. If it goes down, tomcat 2 
intermittently restores it from memcached.

If I reverse it, when ubunutu goes down, Redhat tomcat fails to initialize the 
session due to what I see above.

Maybe you have 2 cents, and any settings I need to set. 

Thanks,
Jay

Original issue reported on code.google.com by jayd.low...@gmail.com on 10 Dec 2012 at 11:30

GoogleCodeExporter commented 8 years ago
The title is incorrect, loading from memcached 2X where delete is called in 
between. The second load fails to load the session, thus the session is lost. 
Can we turn this "removeFromMemcached" off?

Original comment by jayd.low...@gmail.com on 10 Dec 2012 at 11:33

GoogleCodeExporter commented 8 years ago
The invocation of MemcachedBackupSessionManager.remove should be caused by a 
session expiration.

As long as your code does not call this, I wonder what's the reason for it.

Did you check that the server time is the same on both machines? That you only 
experience this from one machine to the other but not the other way around 
might be a hint on a server time mismatch, too.

Original comment by martin.grotzke on 11 Dec 2012 at 9:21

GoogleCodeExporter commented 8 years ago
Hello Martin,

Good point. There was a few lag between 2 machines. I was actually looking at 
the code and looking why that is called, and I noticed that there was a 
background task that sweeps through the sessions and cleans up.

Great stuff. I actually like this solution over the clustering between tomcats.

Thanks,
Melvin

Original comment by jayd.low...@gmail.com on 11 Dec 2012 at 11:16

GoogleCodeExporter commented 8 years ago
Thanx! :-) So it's working now?

Original comment by martin.grotzke on 11 Dec 2012 at 11:19

GoogleCodeExporter commented 8 years ago
Yes! It works very well. I would put more testing around this because I want to 
put this live on our production systems.

If I find more issues I'll let you know. :)

Cheers!
Melvin 

Original comment by jayd.low...@gmail.com on 12 Dec 2012 at 9:42

GoogleCodeExporter commented 8 years ago
Ok, great!

Original comment by martin.grotzke on 13 Dec 2012 at 8:17

GoogleCodeExporter commented 8 years ago
Hi,

I am having clustering environment with 2 memcache instances and 2 servers and 
added the jars in tomcat lib directory which are available in the site 
https://code.google.com/p/memcached-session-manager/wiki/SetupAndConfiguration  

While disabling the cookies am getting the data from the session.

problem:
========
But with enabling cookies am not getting data from the session with multiple 
tabs on the same browser hitting at the same time.

Expected:
========
It should work with enabling/Disabling cookies.

Configuration in context.xml of tomcat:

<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
    memcachedNodes="n1:localhost:11211"
    sticky="false" 
    operationTimeout="60000" 
    sessionBackupTimeout="300000"
    sessionBackupAsync="false"
    lockingMode="none"
transcoderFactoryClass="de.javakaffee.web.msm.JavaSerializationTranscoderFactory
"
    />

Previous without clustering able to get the data in multiple tabs.

When am searching with different search criterias in multiple tabs am able to 
get the data in one tab and am getting session as null for other tab in same 
browser.

Thanks.

Original comment by run2chak...@gmail.com on 24 May 2013 at 1:12