开发环境、测试环境均没有问题,上生产报错如下:

2022-11-07 17:04:41.259|ERROR^|[i.n.u.concurrent.DefaultPromise.rejectedExecution:844]^|[8bc5b07e4ee0d7ed,8bc5b07e4ee0d7ed]^|Failed to submit a listener notification task. Event loop shut down?
java.util.concurrent.RejectedExecutionException: event executor terminated
        at io.netty.util.concurrent.SingleThreadEventExecutor.reject(SingleThreadEventExecutor.java:926)
        at io.netty.util.concurrent.SingleThreadEventExecutor.offerTask(SingleThreadEventExecutor.java:353)
        at io.netty.util.concurrent.SingleThreadEventExecutor.addTask(SingleThreadEventExecutor.java:346)
        at io.netty.util.concurrent.SingleThreadEventExecutor.execute(SingleThreadEventExecutor.java:828)
        at io.netty.util.concurrent.SingleThreadEventExecutor.execute(SingleThreadEventExecutor.java:818)
        at io.netty.util.concurrent.DefaultPromise.safeExecute(DefaultPromise.java:842)
        at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:499)
        at io.netty.util.concurrent.DefaultPromise.addListener(DefaultPromise.java:184)
        at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:95)
        at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:30)
        at org.redisson.command.CommandAsyncService.lambda$async$5(CommandAsyncService.java:789)
        at org.redisson.misc.RedissonPromise.lambda$onComplete$0(RedissonPromise.java:187)
        at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:578)
        at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:552)
        at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:491)
        at io.netty.util.concurrent.DefaultPromise.addListener(DefaultPromise.java:184)
        at org.redisson.misc.RedissonPromise.onComplete(RedissonPromise.java:181)
        at org.redisson.command.CommandAsyncService.async(CommandAsyncService.java:770)
        at org.redisson.command.CommandAsyncService.readAsync(CommandAsyncService.java:427)
        at org.redisson.spring.data.connection.RedissonConnection.read(RedissonConnection.java:838)
        at org.redisson.spring.data.connection.RedissonConnection.hGet(RedissonConnection.java:1466)
        at org.springframework.data.redis.core.DefaultHashOperations.lambda$get$0(DefaultHashOperations.java:53)
        at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:228)
        at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:188)
        at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:96)
        at org.springframework.data.redis.core.DefaultHashOperations.get(DefaultHashOperations.java:53)
        at com.yonyou.cloud.dmsretail.service.impl.DeliveryCarServiceImpl.queryDeliveryPage(DeliveryCarServiceImpl.java:273)

首先到开发环境中排查问题,发现却复现不了

查阅资料后有了以下思路:

1、redisson-spring-boot-starter 的版本太低,需要升级版本

2、根据报错信息,重点分析(DeliveryCarServiceImpl.java:273)这里的代码

思考着,如果升级JAR版本,目前系统已经运营1年多,升级JAR之后,对系统中的功能点影响有多大,不好估量,所以暂时不尝试这个方案。

那就重点看代码吧

 但是我觉得问题也不是这里,这是需要优化,key值为空的话,只是在redis缓存中获取不到而已,不应该报上面的错误

继续查阅资料,发现应该是触发了线程池的拒绝策略,线程池跑满导致的。

带着这个问题,再仔细看看上面这段代码,似乎明白了其中缘由。故优化代码如下:

一次性取出缓存map,不再循环去连接redis获取数据,减少线程池的连接数。

等部署上线后,观察一段时间,再来补充文档。 

 

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐