do you see exceptions or s.th. else interesting in the logs? Do you
see that msm is initialized at startup?
To increase the log level for msm you should add some entries to
$CATALINA_HOME/conf/logging.properties:
de.javakaffee.web.msm.SessionTrackerValve.level = FINE
de.javakaffee.web.msm.MemcachedBackupSessionManager.level = FINE
de.javakaffee.web.msm.NodeAvailabilityCache.level = FINE
Perhaps you need also change the level of the ConsoleHandler like this:
java.util.logging.ConsoleHandler.level = FINE
Could you already get msm working on a locally installed tomcat, or
are you starting with this in the environment you described?
It's also possible to see msm in action in a local setup, just restart
a tomcat and see the session loaded from memcached on the next
request, or with two tomcats on different ports, where you can request
the session created on tomcat1 on tomcat2.
Cheers,
Martin
--
Martin Grotzke
http://www.javakaffee.de/blog/
>
> However have now come across a different issue.
>
> The Session seems to exist across all of the servers. (the session
> Session Creation Time seems to be shared correctly to all servers ).
Are you referring to memcached nodes with "servers"? What's your setup
(tomcats, memcached etc.) and what do you do to create this scenario?
> However the actually data object stored in the session comes back as
> null.
> Strangely Some servers seem to share it. Other Show it as null.
Hmm. Is the data object directly stored in the session, or is it just
part of an object stored in the session?
Can you provide some simple sample that I can use to reproduce this issue?
What msm and serialization strategy are you using btw.?
Cheers,
Martin
--
Martin Grotzke
http://www.javakaffee.de/blog/
please can you use the attached msm jar and replace the former one in
$CATALINA_HOME/lib/?
Also please set
sessionBackupAsync="false"
in your Manager configuration.
Can you then test session failover / deserialization of the session
and see if there are any exceptions in the logs?
Cheers,
Martin
msmStatAttributesSerializationInfo, msmStatEffectiveBackupInfo,
msmStatMemcachedUpdateInfo and msmStatCachedDataSizeInfo are
interesting stats to track this down.
To make things faster you might want to try kryo as serialization
strategy btw, you can have a look for a simple comparison:
http://code.google.com/p/memcached-session-manager/wiki/SerializationStrategyBenchmark
What's needed to use kryo is described on the SetupAndConfiguration page.
>
> I've setup a quick test of a diffrent approach and just serialiseing a
> single string.
>
> And it seem to always be there.
>
> Would you say its a good idea to keep a user on a certain server for a
> small amount of time to insure the session is persisted?
Depends on the avg time that's needed to push sessions to memcached
(requested number from above)
Just to be sure: you are using sticky sessions. Right?
Cheers,
Martin
>
> Server timeouts are set to around 10 seconds so after that you may get
> forwarded to a different server.
> In the hope that your session is persisted across them all.
>
> I've also now changed all our code to only store a single sting in the
> session instead of a java object.
> Incase that was the problem.
So if you store only a single string, this session is correctly
restored on another server, but not if you store a more complex java
object?
Cheers,
Martin
>
> If you need any more let me know.
--
Martin Grotzke
http://www.javakaffee.de/blog/
Otherwise I wonder why you answer with a "session timeout" when I ask
for session stickyness.
Or dou you really have a session timeout of 10 seconds configured in
tomcat - what I can't believe honestly?
>
> Since i cant seem to get it to store anything now. The only thing that
> seems to be the same on all the servers in the HttpSession.getId().
>
> I did notice a minus memcachedExpirationTime:
>> - wasAccessedSinceLastBackup: true
>> - memcachedExpirationTime: -1284050304
>
> Could this be the cause?
No.
>
> i just tried to add a simple random string to the session but can only
> see it populated on the server that added it.
> When i force the requests to any other server it is null.
How do you "force the requests to any other server"?
>
>
> Also on the sticky session. How long do they need to stick for?
Forget about this.
The problem for me with your issue is that it's not reproducable at
all - or that I don't know what I had to do to reproduce it.
The only way to solve this that I currently see is that you provide a
very simple struts2 webapp that shows your issue, so that I can debug
into the code and see what's going wrong there.
I started playing with a struts2 example yesterday btw, by just
putting struts2-showcase-2.2.1.war (from the struts2 downloads page)
into the webapps directory of the msm sample webapp
(http://github.com/magro/msm-sample-webapp ) and slightly changing the
msm configuration.
The result was that I got a NotSerializableException:
com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector, and
this class could also not be serialized with kryo.
As you don't report this exception, I really wonder what your "setup"
is and how your webapp uses struts. This is another reason why I want
to see a sample webapp that reflects the environment that shall be
supported by msm.
Cheers,
Martin
>
> Thanks again for all the help.
>
> Regards
> James
>
>
>
> On Sep 9, 8:47 pm, Martin Grotzke <martin.grot...@googlemail.com>
> wrote:
>> On Thu, Sep 9, 2010 at 7:11 PM, James P <jsparry.gt...@gmail.com> wrote:
>> > To Answer your other questions.
>>
>> > I'm using a hardware load balancer to balance requests.
>>
>> Is the load balancer configured to use sticky-sessions?
>>
>>
>>
>> > Server timeouts are set to around 10 seconds so after that you may get
>> > forwarded to a different server.
>> > In the hope that your session is persisted across them all.
>>
>> > I've also now changed all our code to only store a single sting in the
>> > session instead of a java object.
>> > Incase that was the problem.
>>
>> So if you store only a single string, this session is correctly
>> restored on another server, but not if you store a more complex java
>> object?
>>
>> Cheers,
>> Martin
>>
>>
>>
>> > If you need any more let me know.
>>
>> --
>> Martin Grotzkehttp://www.javakaffee.de/blog/
--
Martin Grotzke
http://www.javakaffee.de/blog/
thanx for this explanation of your setup. My last point is still true:
I cannot reproduce your issue, even not with this explanation
(obviously I don't know/have your LBs, application, etc.). So please
tell me how I can help you. Alternatively you can follow my suggestion
and provide a simple struts2 sample webapp that I can use to reproduce
your issue. As it's not working in the big/complex setting you have to
start with a small/simple setting to see where it's starting to go
wrong.
Cheers,
Martin
--
Martin Grotzke
http://www.javakaffee.de/blog/
>
> It was the sessionBackupTimeout.
>
> Setting it slightly longer fixed all the errors and all servers see
> the sessions perfectly.
To which value have you set it now? It's only relevant if you have set
sessionBackupAsync=false btw.
Is your session failover now also working with your complex objects,
or are you only storing ids in the session (what I would recommend
:-))?
I noticed one thing that seems to have changed in your setup: In one
of your first mails you mentioned a session id like
7C0----------------------AARW5-dev3.sv-dev-03
so you had configured a jvmRoute "sv-dev-03".
In one of your last postings your session id was e.g.
335D69ED437FA06A035E8EF486667D45-dev
so there was no jvmRoute included.
The first thing will fail with the current version of msm, a jvmRoute
like "svdev03" (not containing a dash) would be ok.
I just fixed this issue, it's now in the repo (if you need a release just ask).
To see more info about session backup in the logs you might add
de.javakaffee.web.msm.BackupSessionService.level = FINE
de.javakaffee.web.msm.BackupSessionTask.level = FINE
to the logging.properties.
Cheers,
Martin
>
> Martin Many Thanks for all your help.
>
> Regards
> James
--
Martin Grotzke
http://www.javakaffee.de/blog/
>
> If there is a benefit would it be possible you could create me a
> release?
>
> Many thanks for all your help.
You're welcome :-)
Cheers,
Martin
--
Martin Grotzke
http://www.javakaffee.de/blog/