BUG: Inconsistent TTL on Session Expiration Sets leading to increasing orphaned keys
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
Research direction
Start in spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisIndexedSessionRepository.java at the MinuteBasedRedisSessionExpirationStore save method around line 1044. Check the first creation of the expiration SET and verify whether its TTL is absent, then confirm the behavior for subsequent entries. Done means newly created expiration tracking SETs receive the intended safety-net TTL without breaking existing refresh behavior.
Written by the indexing model from the issue text.
Description
The current implementation of MinuteBasedRedisSessionExpirationStore does not apply a “safety net” Time-To-Live (TTL) to the expiration tracking SET.
Looking at the save method, we can see that the line
this.redis.boundSetOps(expirationsKey).expire(fiveMinutesAfterExpires, TimeUnit.SECONDS);
does not set the expiry when the key is created for the first time. It only updates the TTL for subsequent keys that fall within the same minute.
I assume this behavior is intentional—to refresh the TTL for an already existing SET key. However, the issue is that when the SET is saved for the first time, it has no TTL applied, which can lead to orphaned keys accumulating over time.
The following snippet shows where the TTL should likely be added:
BoundSetOperations<String, Object> expireOperations = this.redis.boundSetOps(expireKey);
expireOperations.add(keyToExpire);
It seems that the following line is missing:
expireOperations.expire(fiveMinutesAfterExpires, TimeUnit.SECONDS);
Could you please confirm if my understanding is correct and whether this could be a potential bug in the implementation?
- Dominant language
- Java
- Stars
- 1.9k
- Forks
- 1.2k
- Avg merge
- 4h 27m
- Merged PRs (30d)
- 55
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from spring-projects/spring-session
-
status: waiting-for-triage type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
spring-projects/spring-session#3857 · 1 comment ·
-
status: waiting-for-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
spring-projects/spring-session#1729 · 2 comments · 1 reaction ·
-
in: build type: task
spring-projects/spring-session#3958 · 1 comment · 1 assignee ·
-
status: waiting-for-triage type: bug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
spring-projects/spring-session#3827 · 1 comment ·
-
status: waiting-for-triage type: bug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
spring-projects/spring-session#3755 · 5 comments · 1 reaction ·
All issues in spring-projects/spring-session
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100