Export to GitHub

memcached-session-manager - issue #222

Support redis a backend storage


Posted on Dec 16, 2014 by Massive Hippo

This is an enhancement.

We used https://github.com/jcoleman/tomcat-redis-session-manager as a redis tomcat session manager.

Unfortunately we had some legacy parts using session heavily and there were racing conditions. The reason is that two ajax requests will deerialize from redis and have a copy of session, when finishing, they two will write to redis and the later one win and override the earlier one.

Your session persistence strategy seems to fit our need, but look at the codes I don't know how to change it to support redis.

If I understand correctly, it should be trivial to switch backend storage if designed well.

Please have a look whether it is possible to support redis as an external storage.

Comment #1

Posted on Dec 17, 2014 by Grumpy Bear

There was once a pull request (https://github.com/magro/memcached-session-manager/pull/18) from which I created a branch (https://github.com/magro/memcached-session-manager/tree/pluggable-storage-pull18). While working on this I ran into issues with integration tests and redis failover tests, I just couldn't get them to work. If you'd like to pick up the work on this I could see if I've everything pushed or if I have still some work in progress locally.

Cheers, Martin

Comment #2

Posted on Dec 17, 2014 by Massive Hippo

Hi,

I am interested, please help to push all related changes to a separate branch and I'll have a look.

By the way, I think the session manager shouldn't concern about the failover of the storage. In redis, you could use Redis Sentinel to manage redis nodes and failover stuff. So the session manager only need to know the sentinel nodes. Sentinel nodes will manage the rest nodes for you. That way the session manager should be simpler.

Personally I think the responsibility of session manager is just purely persistence.

Cheers, Rui

Comment #3

Posted on Dec 17, 2014 by Grumpy Bear

Hi Rui,

great that you're interested! I'll check tomorrow when I'm back at my pc if everything's pushed.

Basically I agree with you that msm should not be concerned with the backend high availability / failover, but this implies that you need a HA backend and a driver that manages HA transparently for msm. Because I started msm with memcached, there was no such a solution. Later, when membase was available and mature, I added membase support, where in fact the driver manages HA transparently. AFAICS for redis sentinel you'd need https://github.com/hamsterready/jedis-sentinel-pool, or is there a better solution?

Cheers, Martin

Comment #4

Posted on Dec 17, 2014 by Grumpy Bear

Alternatively redis cluster + Jedis Cluster might be an option. Have you used this already, what do you think?

Comment #5

Posted on Dec 18, 2014 by Massive Hippo

Hi,

Sorry, with redis sentinels, you may also need two sentinels nodes for redundancy. So the session manager does need to manage a node list.

Cheers, Rui

Comment #6

Posted on Dec 18, 2014 by Massive Hippo

basically we set up two redis nodes and two sentinels nodes. we passed sentinels nodes to tomcat-redis-session-manager. And looking at its codes, it is using jedis JedisSentinelPool to manage connection pool.

Cheers, Rui

Comment #7

Posted on Dec 18, 2014 by Grumpy Bear

Hi Rui,

I just checked it, the branch "pluggable-storage-pull18" on github is up to date. At that time I tried to setup a redis sentinel integration test based on embedded-redis but there were issues in test mode (while redis sentinel worked when testing manually), I just pushed my stuff to https://github.com/magro/embedded-redis (the main repo is newer, so my version is outdated, perhaps the new upstream stuff already improves things).

Cheers, Martin

Comment #8

Posted on Dec 18, 2014 by Massive Hippo

Hi Martin,

Thanks. I will play with it once I have the time.

Cheers, Rui

Comment #9

Posted on Jan 9, 2015 by Massive Hippo

Hi Martin,

try to generate idea project using: mvn idea:idea

got dependency exception: Failed to execute goal on project memcached-session-manager-tc6: Could not resolve dependencies for project de.javakaffee.msm:memcached-session-manager-tc6:jar:1.6.3-SNAPSHOT: The following artifacts could not be resolved: de.javakaffee.msm:memcached-session-manager:jar:1.6.3-SNAPSHOT, de.javakaffee.msm:memcached-session-manager:jar:tests:1.6.3-SNAPSHOT: Could not transfer artifact de.javakaffee.msm:memcached-session-manager:jar:1.6.3-SNAPSHOT from/to jmemcached (http://thimbleware.com/maven): thimbleware.com: Unknown host thimbleware.com -> [Help 1]

I know buildr. But I am a basic mvn user. I am guessing that I need to do local publish. any idea how I can quickly workaround this?

Cheers, Rui

Comment #10

Posted on Jan 9, 2015 by Grumpy Bear

Hi Rui,

I just removed the thimbleware.com/maven repository in pom.xml, because the artifacts are now available in maven central.

https://github.com/magro/memcached-session-manager/commit/da265b91

Cheers, Martin

Comment #11

Posted on Aug 24, 2015 by Grumpy Bear

Issues are moved to github, this one is now https://github.com/magro/memcached-session-manager/issues/261

Status: New

Labels:
Type-Defect Priority-Medium