spring-projects / spring-projects/spring-session

After `changeSessionId`, expirationStore(ordered set) lost the new sessionId

Open
#3,363 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage type: bug
Dominant language
Java
Stars
1.9k
Forks
1.2k
Avg merge
4h 27m
Merged PRs (30d)
55

Description

Describe the bug

After changeSessionId, expirationStore(ordered set) lost the new sessionId

To Reproduce

  1. config SortedSetRedisSessionExpirationStore for expirationStore
  2. Create a new session and save it
  3. FindById to get the previously saved session
  4. Call changeSessionId and save it
  5. You can see in the expiration kv of redis that the new sessionId does not exist

Expected behavior

The old sessionId should be deleted and the new sessionId should be appended to the sorted set of redis

Source

https://github.com/spring-projects/spring-session/blob/2353d8b3cec4f0ed104c45f10d01acf278fe1dad/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisIndexedSessionRepository.java#L994

How to fix

We can add a rename method to the RedisSessionExpirationStore interface

rename(String oldSessionId, String newSessionId, Integer expirationInMillis)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at RedisIndexedSessionRepository.java around line 994 and inspect the RedisSessionExpirationStore interface and its expiration-store implementations. Reproduce the changeSessionId flow with SortedSetRedisSessionExpirationStore, then verify that the old sessionId is removed and the new one is present in Redis's expiration sorted set.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, redis, spring
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.