Closed
Description
@rwinch We are using spring-session 1.2.0.RC1 and spring-data-redis 1.7.0.RC1. Somehow we are not getting the listener call back if we use redis cluster. It works perfect if we use a stand-alone redis server. I have uploaded a sample springSessionContext.xml.
On one of the nodes in redis cluster, we see "SUBSCRIBE" "__keyevent@:expired" "spring:session:event:created:" "__keyevent@*:del" command. So it does subscribe on one node. Should it subscribe to all nodes in the cluster? Or this is expected behavior?
Sample application code is available here.
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
rwinch commentedon Apr 11, 2016
Thanks for the report!
cc @christophstrobl
leehanwool commentedon Apr 12, 2016
I experienced same situation at tomcat 8 with spring-web-application(spring-data-redis 1.7.1.RELEASE) and redis-cluster(3.0.7).
When I stop tomcat, I received WARNING message like below, then tomcat going to hanging status, so I have to kill tomcat myself.(sometimes stop tomcat oneself after few minutes.)
would you please tell me about release plan with this issue?
rwinch commentedon Apr 12, 2016
@leehanwool I haven't had a chance to look into this issue yet. Note that we also have a ticket for official Redis Cluster support that we need to get to. See #422
As for your StackTrace, could you please create a separate ticket for the unclosed thread?
christophstrobl commentedon Apr 12, 2016
@rwinch @leehanwool created DATAREDIS-493 to check that.
leehanwool commentedon Apr 13, 2016
@rwinch
Thank for reply.
I created new #482 ticket for Stacktrace.
nirav-patel commentedon Apr 15, 2016
@rwinch @leehanwool @christophstrobl
I have done spring-session configuration with Redis by using Jedis Client (2.8.1 version) as mentioned in issue description by @sanketmeghani above. I found that internally when cluster is created, each node gets subscribed to patterns for event notifications (basically those are session creation, session expiration and session deletion events) via method
void redis.clients.jedis.BinaryJedisCluster.psubscribe(BinaryJedisPubSub jedisPubSub, byte[]... patterns)
Actual implementation of the method in BinaryJedisCluster class is as shown below:
Note in execute method, Jedis Connection is subscribed to patterns using subscribe method [i.e.
connection.subscribe(jedisPubSub, patterns);
].Here If I override this method with custom implementation and subscribe each Jedis Connection in execute method with psubscribe method instead of subscribe method [i.e.,
connection.psubscribe(jedisPubSub, patterns)
], then I`m able to retrieve session notifications for creation, expiration and deletion activities performed by Redis Cluster.In case of single Redis node implementation, Jedis Connection is subscribed to patterns using psubscribe method and not the subscribe method. So I applied the same logic for Redis Cluster use-case too and things are working fine.
I don`t know whether it is a Jedis issue or current implementation is correct for some purpose.
Is this a correct way to fix above issue and get session listeners call backs from Redis Cluster?
@rwinch @leehanwool @christophstrobl Please provide your feedback for this solution.
rwinch commentedon Apr 15, 2016
@nirav-patel Thanks for the detailed writeup!
I think @christophstrobl will be able to provide better feedback on your solution
leehanwool commentedon Apr 18, 2016
@nirav-patel , Thank you for advise!
I tried to use your solution in my case #482
It works perfectly. Tomcat no more going to hanging status, So I don't need kill tomcat anymore.
Thank you!!!
christophstrobl commentedon Apr 18, 2016
thanks @nirav-patel for detailed information.
HeartSaVioR commentedon Apr 18, 2016
Thanks all for finding missed spot for Jedis.
rwinch commentedon May 2, 2016
Thanks for the reports and helping sort this out! I'm closing this as it appears the issue has been fixed in Jedis
horance commentedon Jan 11, 2018
@rwinch Sorry about commenting on closed issue. I ran into the issue that @sanketmeghani mentioned.
I've done a sample project SpringSessionTest with spring-session 1.3.0.RELEASE and spring-data-redis 1.8.3.RELEASE. I've found redis message listener container only subscribed to one node. According to https://github.com/antirez/redis/issues/2541, the keyspace notifications are only sent locally. As a result, the session-expired event will not be processed by listener, unless the key was created on the subscribed node.
Following is my test result with my test application, I send two http request to my test application with curl:
And after couple minutes, the log shows the first session expired event have been received and processed, but the second session was not.
Please help to re-investigate this issue,
thanks a lot!!
christophstrobl commentedon Jan 11, 2018
@horance we've got an open issue in Spring Data Redis to tackle this. Please see: DATAREDIS-534.