使用场景
- 我们使用redis作为缓存服务,缓存一些业务数据,如路口点位信息、渠化信息、设备信息等
- 有一些需要实时计算的数据,缓存在redis里,如实时信号周期相位、周期内过车数量等
- 有需要不同服务访问的数据,使用redis作为共同可访问操作的缓存空间
报错信息
- 在数据库数据变动时,需要清楚redis里的缓存,等下次查询需要时从数据库查询,再写入redis
- 此时删除数据报错,核心报错信息
Read timed out
,连接超时
- 检查了下,redis服务正常
- 具体报错信息,分两个时间点的报错,(截取部分)如下:
- 报错日志一JedisConnectionException:
2023-03-29 10:54:38.186 ERROR 9136 --- [ntainer#7-0-C-1] c.n.r.service.IntersectionQueryService : Exception in getIntersectionById() with cause = 'redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: Read timed out' and exception = 'java.net.SocketTimeoutException: Read timed out; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: Read timed out'
org.springframework.data.redis.RedisConnectionFailureException: java.net.SocketTimeoutException: Read timed out; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: Read timed out
at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:65)
at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:42)
at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:44)
at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:42)
at org.springframework.data.redis.connection.jedis.JedisConnection.convertJedisAccessException(JedisConnection.java:187)
at org.springframework.data.redis.connection.jedis.JedisConnection.doWithJedis(JedisConnection.java:802)
2023-08-24 09:44:23.721 ERROR 92250 --- [ns-pool-evictor] redis.clients.jedis.JedisFactory : Error while validating pooled Jedis object.
redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: Read timed out
at redis.clients.jedis.util.RedisInputStream.ensureFill(RedisInputStream.java:205)
at redis.clients.jedis.util.RedisInputStream.readByte(RedisInputStream.java:43)
at redis.clients.jedis.Protocol.process(Protocol.java:162)
at redis.clients.jedis.Protocol.read(Protocol.java:227)
at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:352)
at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:270)
at redis.clients.jedis.BinaryJedis.ping(BinaryJedis.java:380)
at redis.clients.jedis.JedisFactory.validateObject(JedisFactory.java:214)
at org.apache.commons.pool2.impl.GenericObjectPool.evict(GenericObjectPool.java:745)
at org.apache.commons.pool2.impl.BaseGenericObjectPool$Evictor.run(BaseGenericObjectPool.java:160)
解决方式
spring:
redis:
jedis:
pool:
min-idle: 10
max-idle: 300 # 改大了
max-wait: 30000 # 改大了
max-active: 200 # 改大了
core-app:
image: june
container_name: core
volumes:
- /etc/localtime:/etc/localtime
depends_on:
- postgresql
- redis
environment:
- _JAVA_OPTIONS=-Xmx6G -Xms1G
- SERVER_PORT=8181
- SPRING_PROFILES_ACTIVE=prod,api-docs,no-liquibase
- SPRING_DATASOURCE_URL=jdbc:postgresql://postgresql:5432/core
- SPRING_DATASOURCE_USERNAME=xxxx
- SPRING_DATASOURCE_PASSWORD=xxxxxxx
- SPRING_REDIS_HOST=redis
- SPRING_REDIS_PASSWORD=xxxxxxxx
- spring_redis_jedis_pool_maxIdle=300 # redis配置
- spring_redis_jedis_pool_maxWait=30000
- spring_redis_jedis_pool_maxActive=200
restart: on-failure
原文地址:https://blog.csdn.net/u010882234/article/details/132479363
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_33338.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。