-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Spring Session Redis is not clearing expired index to sessions in Redis #2166
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
I have the same problem, do you have a solution? |
@baozi-2019 disabled spring session redis is in Reactor project. |
Hi, @git-syl. Thanks for the report. I'm confused, we do not have an indexed Redis implementation for Reactive, therefore it is not possible to have a Your sample has too many things going on, can you make it minimal? |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Hi @marcusdacoregio ,Thank you for your response. I speculate that there is some code inside ReactiveRedisSessionRepository(spring-session-data-redis-2.6.3.jar) to renew the redisKey & Modifying the redisKey causes the login project to be unable to clear the redis key. |
Hello, @git-syl. Which Redis keys are you talking about? Is it the index key (which should not exist in the reactive implementation), or is it the session key? It is important to note that Redis may not remove all expired keys instantly. In addition to that, there was a bug on older versions of Spring Session Redis Reactive where it would fail to set the expiration time to a key. |
It is the index key. After accessing the index key in this class, the index key will persist indefinitely and won't be automatically cleared.(Even if the project is set with spring.session.timeout=20s) If I'm not mistaken, under normal circumstances, the index key Other servlet projects will receive a large number of failed clean-up logs, and the source code is located at: Thank you very much in the end. I appreciate you mentioning issue #2464. |
I'm a bit confused because you mentioned Spring WebFlux apps and the problem is related to the index key which is created by an indexed session repository implementation, in that case, The Redis documentation for expire says:
That means that even if the key is expired, it might not be instantly removed from the database. The I'll close this since it appears that the behavior is expected, if you still think that this is a bug in Spring Session, please add a minimal, reproducible sample where we can debug the behavior consistently. |
Describe the bug
I integrated Spring Session into my project.
I found that the Spring Boot (Servlet container) and spring boot WebFlux (reactor project )integrated Spring sessions at the same time, which caused the redis key to not expire.
spring:session:index:org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME:
spring:session:index:org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME:
spring:session:index:org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME:
...
In Redis many keys failed to clean, resulting in memory overflow.
And My Spring Boot (Servlet container) Application with some WARN :
2022-09-22 17:11:33.171 WARN 23620 --- [nerContainer-49] o.s.s.d.r.RedisIndexedSessionRepository : Unable to publish SessionDestroyedEvent for session 727ae15d-7f42-4f8d-b229-f8385ac54b06
To Reproduce
spring boot 2.6.11
spring-session-data-redis 2.6.3
Steps to reproduce the behavior:
STEP-01 : Login and get token, in login project , it is Spring Boot applicaiton (Servlet container)
STEP-02 : Access RESTFUL api in reactor project immediately.
STEP-03 : Wait abount 30 seconds and view logs. Or look`t the data in Redis
test code like :
Expected behavior
Automatically clean keys (spring:session:index:org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME:),
when the session expires.
Sample
https://github.com/sunyl-git/sunyl-git-spring-reactor-session-issue-report-sample
In my limited experience with Spring, Thanks in advance!
The text was updated successfully, but these errors were encountered: