Skip to content

org.redisson.tomcat.RedissonSessionManager renders tomcat8 useless if Redis server is down #1651

Open

Description

@larsgv

Exception thrown if Redis-server is down, causes apps to stop working.
This might be an intended behavior, but the presence of the centralized session backup is not mission critical for our system (only used for failover). But using this session manager will actually introduce a new critical error to our system, when/if the Redis server goes down.

A flag/setting where communication errors with Redis would be logged instead of causing a "crash" would be highly appreciated.

Expected/Wanted behavior

Tomcat uses the local session to service the request and ignores any store/find session issues related to communication with Redis-server.

Actual behavior

An Exception is thrown.

Steps to reproduce or test case

Load a page on tomcat where a session is created and attribute is added to it. Turn of Redis-server and reload the page.

Redis version

3.0.6

Redisson version

3.7.5

Redisson configuration

Manager is set up with readMode="MEMORY" and updateMode="DEFAULT"


singleServerConfig:
address: "redis://localhost:6379"
subscriptionConnectionMinimumIdleSize: 1
subscriptionConnectionPoolSize: 50
connectionMinimumIdleSize: 32
connectionPoolSize: 64
database: 0
dnsMonitoringInterval: 5000
transportMode: "EPOLL"
useLinuxNativeEpoll: true

Activity

  1. qupera commented on Sep 2, 2019

    @qupera

    Is this feature planned to be implemented? It is very important to us as well. Any feedback on this would be greatly appreciated.
    Thx in advance

  2. added this to the 3.15.5 milestone on Apr 25, 2021
  3. modified the milestones: 3.15.5, 3.15.6 on May 13, 2021
  4. modified the milestones: 3.15.6, 3.16.0 on Jun 8, 2021
  5. modified the milestones: 3.16.0, 3.16.1 on Jun 21, 2021
  6. modified the milestones: 3.16.1, 3.16.2 on Jul 26, 2021
  7. modified the milestones: 3.16.2, 3.16.3 on Sep 5, 2021
  8. jglapa commented on Sep 6, 2021

    @jglapa
    Contributor

    Yes, please. Some kind of graceful handling of temporary redis downtime would be appreciated(maybe fallback to some other session management implementation?) .

    When redis goes down or connectivity with it is interrupted whole tomcat blows up serving nasty error pages which cannot be even intercepted. e.g.
    image

    Users are facing similar problems in other cases e.g. https://stackoverflow.com/questions/62127697/tomcat-not-handling-500-internal-server-code-thrown-by-external-service

  9. 36 remaining items

  10. modified the milestones: 3.19.2, 3.19.3, 3.19.4 on Feb 2, 2023
  11. modified the milestones: 3.19.4, 3.20.1 on Mar 2, 2023
  12. modified the milestones: 3.20.1, 3.20.2 on Mar 28, 2023
  13. modified the milestones: 3.21.0, 3.21.1 on May 1, 2023
  14. modified the milestones: 3.21.1, 3.21.2 on May 12, 2023
  15. modified the milestones: 3.21.2, 3.12.x on May 19, 2023
  16. adbhutrai commented on Sep 25, 2024

    @adbhutrai

    We are using Redisson's Tomcat10 session manager going against Azure Redis Cache with following configuration. Our application is based on Spring MVC.

    Redisson version:
    3.35.0

    Redisson configuration:
    {
    "singleServerConfig": {
    "idleConnectionTimeout": 10000,
    "connectTimeout": 10000,
    "timeout": 3000,
    "retryAttempts": 3,
    "retryInterval": 1500,
    "subscriptionsPerConnection": 5,
    "clientName": null,
    "address": "rediss://:******************************@server.server.net:6380",
    "subscriptionConnectionMinimumIdleSize": 1,
    "subscriptionConnectionPoolSize": 50,
    "connectionMinimumIdleSize": 10,
    "connectionPoolSize": 64,
    "database": 0,
    "dnsMonitoringInterval": 5000
    },
    "threads": 0,
    "nettyThreads": 0,
    "lazyInitialization": true,
    codec: !<org.redisson.codec.SerializationCodec> {}
    }

    Tomcat redisson session manager config:
    <Manager className="org.redisson.tomcat.RedissonSessionManager" configPath="${catalina.base}/redisson.conf" readMode="MEMORY" broadcastSessionEvents="true" updateMode="AFTER_REQUEST"/>

    Here is the stack trace of the logs. Thanks
    24-Sep-2024 15:55:41.879 SEVERE [main] org.apache.catalina.core.StandardContext.startInternal The session manager failed to start
    org.apache.catalina.LifecycleException: Failed to start component [RedissonSessionManager[StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]]
    at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:402)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:179)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4441)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:599)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:571)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:654)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:969)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1911)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:123)
    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:771)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:423)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1629)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:109)
    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:385)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:332)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:776)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:772)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1203)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1193)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:749)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:203)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:415)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:874)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:757)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:569)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:345)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:473)
    Caused by: org.redisson.client.RedisConnectionException: java.util.concurrent.ExecutionException: org.redisson.client.RedisConnectionException: Unable to connect to Redis server: down-test.redis.cache.windows.net/1.1.1.1:6380
    at org.redisson.connection.MasterSlaveConnectionManager.doConnect(MasterSlaveConnectionManager.java:228)
    at org.redisson.connection.MasterSlaveConnectionManager.connect(MasterSlaveConnectionManager.java:188)
    at org.redisson.connection.MasterSlaveConnectionManager.lazyConnect(MasterSlaveConnectionManager.java:172)
    at org.redisson.connection.MasterSlaveConnectionManager.getEntry(MasterSlaveConnectionManager.java:466)
    at org.redisson.connection.MasterSlaveConnectionManager.getWriteEntry(MasterSlaveConnectionManager.java:473)
    at org.redisson.pubsub.PublishSubscribeService.getEntry(PublishSubscribeService.java:582)
    at org.redisson.pubsub.PublishSubscribeService.subscribe(PublishSubscribeService.java:381)
    at org.redisson.RedissonTopic.addListenerAsync(RedissonTopic.java:127)
    at org.redisson.RedissonTopic.addListenerAsync(RedissonTopic.java:123)
    at org.redisson.RedissonTopic.addListener(RedissonTopic.java:110)
    at org.redisson.tomcat.RedissonSessionManager.startInternal(RedissonSessionManager.java:350)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
    ... 40 more
    Caused by: java.util.concurrent.ExecutionException: org.redisson.client.RedisConnectionException: Unable to connect to Redis server: down-test.redis.cache.windows.net/1.1.1.1:6380
    at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
    at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2096)
    at org.redisson.connection.MasterSlaveConnectionManager.doConnect(MasterSlaveConnectionManager.java:223)
    ... 51 more
    Caused by: org.redisson.client.RedisConnectionException: Unable to connect to Redis server: down-test.redis.cache.windows.net/1.1.1.1:6380
    at org.redisson.connection.ConnectionsHolder.lambda$createConnection$2(ConnectionsHolder.java:165)
    at java.base/java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:934)
    at java.base/java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:911)
    at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
    at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2162)
    at org.redisson.connection.ConnectionsHolder.lambda$createConnection$5(ConnectionsHolder.java:179)
    at java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863)
    at java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:841)
    at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
    at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2162)
    at org.redisson.client.RedisClient$1$2.run(RedisClient.java:304)
    at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:994)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:840)
    Caused by: java.util.concurrent.CompletionException: io.netty.channel.ConnectTimeoutException: connection timed out after 10000 ms: down-test.redis.cache.windows.net/1.1.1.1:6380
    at java.base/java.util.concurrent.CompletableFuture.encodeRelay(CompletableFuture.java:368)
    at java.base/java.util.concurrent.CompletableFuture.completeRelay(CompletableFuture.java:377)
    at java.base/java.util.concurrent.CompletableFuture$UniRelay.tryFire(CompletableFuture.java:1097)
    ... 11 more
    Caused by: io.netty.channel.ConnectTimeoutException: connection timed out after 10000 ms: down-test.redis.cache.windows.net/1.1.1.1:6380
    at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe$1.run(AbstractNioChannel.java:263)
    at io.netty.util.concurrent.PromiseTask.runTask(PromiseTask.java:98)
    at io.netty.util.concurrent.ScheduledFutureTask.run(ScheduledFutureTask.java:156)
    ... 8 more
    24-Sep-2024 15:55:41.879 SEVERE [main] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions