-
Notifications
You must be signed in to change notification settings - Fork 1.1k
@EnableRedisWebSession, some sessions do not set a timeout when they are stored in redis, but never expire. #2464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, @SheldonLi666. It is not clear to me why that is happening yet. Is it possible that you set the Can you create a minimal, reproducible sample where we can debug it on our side? |
Hi @marcusdacoregio. First of all, I did not set Excluding project business, my project only uses spring webflux, spring security and spring session, and there are health checks in the online and test environments that request my project interface every 10s to determine connectivity. Nothing else. In addition, this never-expired session will only appear when it is first created. If the session is not accessed subsequently, there will be no problem of no expiration time. I think this problem occurs in |
Hi, @SheldonLi666. Can you put together a sample that demonstrates that |
Hi, @marcusdacoregio. I'm glad to see your reply.
|
@SheldonLi666 before the Contributors fixed the bug,you can add filter to deal with this problem,in the filter you can create the hash with redis api manually before the spring websessionmanager creates it and set TTL for it; alternatively,you can create scheduled tasks to scan the keys with specific prefix,and set a expiration for it |
Hi, @Annaseron |
Thanks everyone for your help on this. This is now fixed in |
My project uses the spring webflux framework and uses spring-session-data-redis to store sessions.
[project spring version]
[question]
After using
@EnableRedisWebSession
to enable the use of spring session framework. Checking redis will find that some hashkeys starting with spring:session:sessions: will never expire, that is, ttl = -1. What's going on?I tried to find the source code and debug it, and found that in the class
org.springframework.session.data.redis.ReactiveRedisSessionRepository
, when the save() method was called for the first time, the internal saveDelta() executed hmset and expire separately. code show as below:You can see that the two monos
update.and(setTtl)
are executed like this. Could it be that the order is out of order for this reason, causingexpire
to be executed first and thenhmset
?Observing the redis log should be able to prove my guess:
The following is one of the reasons why the key never expires that I found by observing the monitor log of redis:
Finally, execute to check this key, it will indeed never expire:

The text was updated successfully, but these errors were encountered: