Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

SessionListener attempts to remove session from distributed storage #142

Open
jorgheymans opened this issue Oct 8, 2024 · 1 comment
Open

Comments

@jorgheymans
Copy link

jorgheymans commented Oct 8, 2024

In my attempts to isolate behaviour for https://vaadin.com/forum/t/continous-deployment-and-vaadin/167127/15 , I noticed that SessionListener attempts to delete the session from distributed storage during shutdown of the application. It fails to do so however as the Spring application context is closed by the time the listener is invoked.

I have 2 remarks on this:

  • when the instance is shut down, and the user with said session cookie closes the browser before interacting with the application again, is associated session data in redis effectively orphaned ? (EDIT i guess this is described here Allow backend connector to apply expiration policies based on HTTP session timeout #126)
  • why does the session need to be removed from redis here, as another application instance could resume serving the user and hence would need that session data to be present ?
Unable to delete data with key fe213d5a-198f-4719-a31f-de08fddef39d from distributed storage associated to session 9EA09A9E52C4FAF243F281FB4C85876D

java.lang.IllegalStateException: LettuceConnectionFactory was destroyed and cannot be used anymore
	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.assertStarted(LettuceConnectionFactory.java:1447) ~[spring-data-redis-3.3.4.jar!/:3.3.4]
	at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getConnection(LettuceConnectionFactory.java:1045) ~[spring-data-redis-3.3.4.jar!/:3.3.4]
	at com.vaadin.kubernetes.starter.sessiontracker.backend.RedisConnector.deleteSession(RedisConnector.java:94) ~[kubernetes-kit-starter-2.2.2.jar!/:2.2.2]
	at com.vaadin.kubernetes.starter.sessiontracker.SessionListener.lambda$sessionDestroyed$0(SessionListener.java:104) ~[kubernetes-kit-starter-2.2.2.jar!/:2.2.2]
	at java.base/java.util.Optional.ifPresent(Optional.java:178) ~[na:na]
	at com.vaadin.kubernetes.starter.sessiontracker.SessionListener.sessionDestroyed(SessionListener.java:99) ~[kubernetes-kit-starter-2.2.2.jar!/:2.2.2]
	at org.apache.catalina.session.StandardSession.expire(StandardSession.java:629) ~[tomcat-embed-core-10.1.30.jar!/:na]
	at org.apache.catalina.session.StandardSession.expire(StandardSession.java:571) ~[tomcat-embed-core-10.1.30.jar!/:na]
	at org.apache.catalina.session.StandardManager.stopInternal(StandardManager.java:384) ~[tomcat-embed-core-10.1.30.jar!/:na]
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:231) ~[tomcat-embed-core-10.1.30.jar!/:na]
	at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:4644) ~[tomcat-embed-core-10.1.30.jar!/:na]
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:231) ~[tomcat-embed-core-10.1.30.jar!/:na]
	at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1219) ~[tomcat-embed-core-10.1.30.jar!/:na]
@jorgheymans
Copy link
Author

jorgheymans commented Oct 18, 2024

This can be fixed by setting server.servlet.session.persistent=true (as recommended by vaadin support), which makes the servlet container not destroy its sessions upon shutdown. It should be a mandatory setting when using kubernetes-kit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant