Skip to content

cleanupExpiredSessionsTask will never run again when exception ocurred in cleanUPExpiredSession method #3426

Open

Description

@tradeshark

Describe the bug
In ReactiveRedisIndexedSessionRepository class, when cleanUpExpiredSession method has exception,like the following stacktrace,the interval task will terminated ,not run next time:

2025-06-20 15:35:18.138 [TID: N/A] [lettuce-eventExecutorLoop-3-1] ERROR reactor.core.publisher.Operators -Operator called default onErrorDropped org.springframework.dao.QueryTimeoutException: Redis command timed out; nested exception is io.lettuce.core.RedisCommandTimeoutException: Command timed out after 5 second(s) at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:70) Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Assembly trace from producer [reactor.core.publisher.MonoError] : reactor.core.publisher.MonoNext$NextSubscriber.onError(MonoNext.java:93) io.lettuce.core.RedisPublisher$ImmediateSubscriber.onError(RedisPublisher.java:891) Error has been observed at the following site(s): *__MonoNext$NextSubscriber.onError ⇢ at io.lettuce.core.RedisPublisher$ImmediateSubscriber.onError(RedisPublisher.java:891) *__________________Flux.onErrorMap ⇢ at org.springframework.data.redis.connection.lettuce.LettuceReactiveRedisConnection.execute(LettuceReactiveRedisConnection.java:224) |_ Flux.next ⇢ at org.springframework.data.redis.connection.ReactiveKeyCommands.exists(ReactiveKeyCommands.java:176) |_ Mono.map ⇢ at org.springframework.data.redis.connection.ReactiveKeyCommands.exists(ReactiveKeyCommands.java:176) *___________________Flux.usingWhen ⇢ at org.springframework.data.redis.core.ReactiveRedisTemplate.doInConnection(ReactiveRedisTemplate.java:242) |_ Mono.from ⇢ at org.springframework.data.redis.core.ReactiveRedisTemplate.doCreateMono(ReactiveRedisTemplate.java:220) |_ Mono.then ⇢ at org.springframework.session.data.redis.ReactiveRedisIndexedSessionRepository.touch(ReactiveRedisIndexedSessionRepository.java:336)

Activity

  1. added
    type: bug
    status: waiting-for-triage
    on Jun 20, 2025
  2. theigl commented on Oct 3, 2025

    @theigl
    Contributor

    We just encountered the same issue. The cleanup job never runs again after an exception.

  3. Keerthana7654 commented on Dec 4, 2026

    @Keerthana7654

    Hi! I'd like to work on this.

    From the stack trace, the failure comes from the Redis call in
    ReactiveRedisIndexedSessionRepository (touch), and the reactive cleanup
    pipeline seems to terminate on the first error with no resubscription.

    My plan:

    • Reproduce it with a unit test (first cleanup tick fails, second succeeds)
    • Handle errors per cleanup run so the job logs and keeps going
    • Keep cleanup disablement (Duration.ZERO / disableCleanupTask) working

    Does this direction sound right? Happy to adjust based on feedback.

  4. Keerthana7654 commented on Dec 4, 2026

    @Keerthana7654

    I've opened a pull request for this: #4205. It handles errors per cleanup run
    with onErrorResume so a failed run is logged and the next scheduled run
    continues. Feedback welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: waiting-for-triagetype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions