美文网首页
Springboot 2.1.9 Jedis偶发READONLY

Springboot 2.1.9 Jedis偶发READONLY

作者: 佑岷 | 来源:发表于2019-10-30 16:37 被阅读0次

    用springboot2.1.9版本时,用redis哨兵模式偶发:

    Caused by: org.springframework.dao.InvalidDataAccessApiUsageException: READONLY You can't write against a read only slave.; nested exception is redis.clients.jedis.exceptions.JedisDataException: READONLY You can't write against a read only slave.
        at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:64) ~[spring-data-redis-2.1.11.RELEASE.jar:2.1.11.RELEASE]
        at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:41) ~[spring-data-redis-2.1.11.RELEASE.jar:2.1.11.RELEASE]
        at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:44) ~[spring-data-redis-2.1.11.RELEASE.jar:2.1.11.RELEASE]
        at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:42) ~[spring-data-redis-2.1.11.RELEASE.jar:2.1.11.RELEASE]
        at org.springframework.data.redis.connection.jedis.JedisConnection.convertJedisAccessException(JedisConnection.java:142) ~[spring-data-redis-2.1.11.RELEASE.jar:2.1.11.RELEASE]
        at org.springframework.data.redis.connection.jedis.JedisHashCommands.convertJedisAccessException(JedisHashCommands.java:448) ~[spring-data-redis-2.1.11.RELEASE.jar:2.1.11.RELEASE]
        at org.springframework.data.redis.connection.jedis.JedisHashCommands.hDel(JedisHashCommands.java:123) ~[spring-data-redis-2.1.11.RELEASE.jar:2.1.11.RELEASE]
        at org.springframework.data.redis.connection.DefaultedRedisConnection.hDel(DefaultedRedisConnection.java:912) ~[spring-data-redis-2.1.11.RELEASE.jar:2.1.11.RELEASE]
        at org.springframework.data.redis.connection.DefaultStringRedisConnection.hDel(DefaultStringRedisConnection.java:440) ~[spring-data-redis-2.1.11.RELEASE.jar:2.1.11.RELEASE]
        at org.springframework.data.redis.core.DefaultHashOperations.lambda$delete$12(DefaultHashOperations.java:234) ~[spring-data-redis-2.1.11.RELEASE.jar:2.1.11.RELEASE]
        at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:225) ~[spring-data-redis-2.1.11.RELEASE.jar:2.1.11.RELEASE]
        at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:185) ~[spring-data-redis-2.1.11.RELEASE.jar:2.1.11.RELEASE]
        at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:96) ~[spring-data-redis-2.1.11.RELEASE.jar:2.1.11.RELEASE]
        at org.springframework.data.redis.core.DefaultHashOperations.delete(DefaultHashOperations.java:234) ~[spring-data-redis-2.1.11.RELEASE.jar:2.1.11.RELEASE]
        at com.pingan.bank.idata.api.listener.CreateRunnerImpl.run(CreateRunnerImpl.java:60) ~[classes/:na]
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:772) [spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
        ... 5 common frames omitted
    Caused by: redis.clients.jedis.exceptions.JedisDataException: READONLY You can't write against a read only slave.
        at redis.clients.jedis.Protocol.processError(Protocol.java:130) ~[jedis-2.9.3.jar:na]
        at redis.clients.jedis.Protocol.process(Protocol.java:164) ~[jedis-2.9.3.jar:na]
        at redis.clients.jedis.Protocol.read(Protocol.java:218) ~[jedis-2.9.3.jar:na]
        at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:341) ~[jedis-2.9.3.jar:na]
        at redis.clients.jedis.Connection.getIntegerReply(Connection.java:266) ~[jedis-2.9.3.jar:na]
        at redis.clients.jedis.BinaryJedis.hdel(BinaryJedis.java:1017) ~[jedis-2.9.3.jar:na]
        at org.springframework.data.redis.connection.jedis.JedisHashCommands.hDel(JedisHashCommands.java:121) ~[spring-data-redis-2.1.11.RELEASE.jar:2.1.11.RELEASE]
        ... 14 common frames omitted
    

    百度、google都没翻到材料。
    最后试了降低jedis版本——将自带的jedis2.9.3降到2.9.0试了十多次感觉可以:

    <dependency>
        <groupId>redis.clients</groupId>
        <artifactId>jedis</artifactId>
        <version>2.9.0</version> //添加此行,默认不填写是2.9.3(springboot 2.1.9.RELEASE)
    </dependency>
    

    相关文章

      网友评论

          本文标题:Springboot 2.1.9 Jedis偶发READONLY

          本文链接:https://www.haomeiwen.com/subject/hauhvctx.html