Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Memory leak in Index for principal null in Redis #1987

Closed
ruslanys opened this issue Dec 28, 2021 · 2 comments · Fixed by #1988
Closed

Memory leak in Index for principal null in Redis #1987

ruslanys opened this issue Dec 28, 2021 · 2 comments · Fixed by #1988
Assignees
Labels
in: redis status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@ruslanys
Copy link
Contributor

Describe the bug

When a user lands at /admin, Spring generates an anonymous session for such user and redirects him to the login page.

When a user passes authentication process, RedisIndexedSessionRepository persists the session identifier in two indexes:

  • session:index:org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME:null
  • session:index:org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME:principalUsername

The issue is that session:index:org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME:null never cleanup: I see hundreds of identifiers under that index.

To Reproduce

  1. Start the sample.
  2. Sign-in using user/password credentials.
  3. Click on the logout button.
  4. Check the index, you will see the record under the key spring:session:index:org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME:null that will never cleanup.

Expected behavior

Do not persist session under null principal, or clean the identifier when the session changes its principal.

Sample

The issue can be reproduced using the sample you have in the repository: https://github.com/spring-projects/spring-session/tree/main/spring-session-samples/spring-session-sample-boot-redis.

@ruslanys
Copy link
Contributor Author

ruslanys commented Dec 28, 2021

The bug goes from #1941 (eb9f62a)

@eleftherias
Copy link
Contributor

Thanks for reaching out @ruslanys. I will be taking a closer look at this in the next few days.

@eleftherias eleftherias added in: redis and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 13, 2022
@eleftherias eleftherias added this to the 2.7.0-RC1 milestone Jan 19, 2022
@eleftherias eleftherias changed the title Memory leak in Index for principal null Memory leak in Index for principal null in Redis Jan 20, 2022
@eleftherias eleftherias added for: backport-to-2.5.x Designates an issue for backport to 2.5.x and removed for: backport-to-2.5.x Designates an issue for backport to 2.5.x labels Jan 20, 2022
@eleftherias eleftherias added the status: backported An issue that has been backported to maintenance branches label Jan 20, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
in: redis status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants