Closed pch851130 closed 5 years ago
Thanks for the report @pch851130 - as mentioned in #1029 (comment), please provide as much details as possible (exact versions you're using, relevant config) or, even better, a minimal, complete, and verifiable example that we can use to reproduce the problem.
I am using this version. The source code is too large to share.
@vpavic May I just ignore that message? What does that message mean? I have read the linked document below, but I do not know what it means. https://github.com/spring-projects/spring-session/issues/1029 https://github.com/spring-projects/spring-session/issues/1047
@vpavic warning occurs even though there is no code to reference the library. if add a library, get a warning. If remove a library, not get a warning.
@pch851130 This message means that session record for which the event was raised was not present when event was handled. You can learn more about how RedisOperationsSessionRepository
handles session expirations and events in the reference manual.
You shouldn't be ignoring these warning, as they suggest something is not right. We've had a few issues related to this, on top of the two issues you link also take a look a #499 and #1128.
warning occurs even though there is no code to reference the library.
If I understand correctly, you're having Spring Boot auto-configure Spring Session for you, and there is no explicit configuration of Spring Session involved? Is anything other interacting with this Redis instance? Are you perhaps using multiple Redis databases inside the same Redis instance (see #1128)?
The source code is too large to share.
Please understand that we need a way to reproduce this issue in order to be able to reliably fix it. Minimal, complete, and verifiable example is not about sharing your existing codebase but rather about creating a minimal sample that can be used to isolate and reproduce the problem.
Closing due to lack of feedback. Please comment back if you can provide more details and we can re-open the issue.
I realize this issue is closed, and I cannot provide a minimum reproduceable example. But I can add more context. In my case, I am seeing this Warning come up in a microservice environment where many services are using redis for a shared session. It appears that when a session expires, the event triggers in all of the services. One of them wins and cleans up the session correctly and the rest of them log the warning message in the OP because the session is no longer found. At least in my case, I have been treating this as ignorable.
spring:session:sessions' Time-To-Live (TTL) should be set to be five minutes longer than the TTL of spring:session:sessions:expires. This ensures that when Redis notifications occur, the session can still be retrieved before it is fully invalidated. If both expire simultaneously, fetching a session would result in NULL and consequently trigger an error like 'Unable to publish SessionDestroyedEvent for session'. The reason for the inconsistency lies in the fact that org.springframework.session.data.redis.ReactiveRedisSessionRepository does not currently implement this specific TTL extension logic, unlike org.springframework.session.data.redis.RedisIndexedSessionRepository which calls org.springframework.session.data.redis.RedisSessionExpirationPolicy.onExpirationUpdated(Long, Session) to manage the TTL difference. In investigating the latest source code up to version 3.2.1, I've observed that ReactiveRedisSessionRepository still does not incorporate the same expiration management logic as RedisIndexedSessionRepository. This disparity could indeed cause issues in reactive web applications such as those using Spring Cloud Gateway. It would be desirable for ReactiveRedisSessionRepository to maintain consistent expiration policy behavior with RedisIndexedSessionRepository to prevent such occurrences. For your request phrased in English: "The TTL of spring:session:sessions
ideally should be configured to be five minutes more than the TTL of spring:session:sessions:expires
, ensuring that during Redis notifications, the session remains retrievable before being fully invalidated. If they expire concurrently, fetching the session would yield NULL, resulting in an error like 'Unable to publish SessionDestroyedEvent for session'. The reason for the TTLs not being different is due to org.springframework.session.data.redis.ReactiveRedisSessionRepository not currently implementing the TTL extension logic present in org.springframework.session.data.redis.RedisIndexedSessionRepository, which invokes org.springframework.session.data.redis.RedisSessionExpirationPolicy.onExpirationUpdated(Long, Session). Upon reviewing the most recent source code up until version 3.2.1, I noticed that ReactiveRedisSessionRepository still lacks this identical expiration management logic, potentially leading to problems in reactive web applications such as those built on Spring Cloud Gateway. It would be beneficial if ReactiveRedisSessionRepository implemented the same expiration policy consistency as RedisIndexedSessionRepository."
how to fix it
when spring boot is upgraded from 1.5.X to 2.X, which causes above warning. is there any way to stop it? warning is output every 3 seconds.