redis服务器重启后redistsmplate异常

时间:2017-01-18 07:19:46

标签: java redis spring-data jedis

使用redisTemplate,一切正常,直到redis服务器重启。然后发生两个例外(见下文)。

当我停止使用redisTemplate.executePipelined时,异常2停止发生。在调用redisTemplate.setEnableTransactionSupport(false);之后,异常1就会消失。

但我不知道为什么。

有什么想法吗?

例外1:

    org.springframework.data.redis.RedisConnectionFailureException: java.net.SocketException: Broken pipe; nested exception is redis.clients.jedis.ex
    ceptions.JedisConnectionException: java.net.SocketException: Broken pipe
            at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:67)
            at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:41)
            at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:37)
            at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:37)
            at org.springframework.data.redis.connection.jedis.JedisConnection.convertJedisAccessException(JedisConnection.java:212)
            at org.springframework.data.redis.connection.jedis.JedisConnection.hGetAll(JedisConnection.java:2890)
            at org.springframework.data.redis.connection.DefaultStringRedisConnection.hGetAll(DefaultStringRedisConnection.java:360)
            at org.springframework.data.redis.core.DefaultHashOperations$13.doInRedis(DefaultHashOperations.java:223)
            at org.springframework.data.redis.core.DefaultHashOperations$13.doInRedis(DefaultHashOperations.java:220)
            at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:204)
            at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:166)
            at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:88)
            at org.springframework.data.redis.core.DefaultHashOperations.entries(DefaultHashOperations.java:220)
            ....
    Caused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: Broken pipe
            at redis.clients.jedis.Protocol.sendCommand(Protocol.java:104)
            at redis.clients.jedis.Protocol.sendCommand(Protocol.java:84)
            at redis.clients.jedis.Connection.sendCommand(Connection.java:127)
            at redis.clients.jedis.BinaryClient.hgetAll(BinaryClient.java:294)
            at redis.clients.jedis.BinaryJedis.hgetAll(BinaryJedis.java:1027)
            at org.springframework.data.redis.connection.jedis.JedisConnection.hGetAll(JedisConnection.java:2888)
            ... 14 common frames omitted
    Caused by: java.net.SocketException: Broken pipe
            at java.net.SocketOutputStream.socketWrite0(Native Method)
            at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
            at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
            at redis.clients.util.RedisOutputStream.flushBuffer(RedisOutputStream.java:52)
            at redis.clients.util.RedisOutputStream.write(RedisOutputStream.java:59)
            at redis.clients.jedis.Protocol.sendCommand(Protocol.java:90)
            ... 19 common frames omitted

例外2:

            org.springframework.dao.InvalidDataAccessApiUsageException: Cannot use Jedis when in Pipeline. Please use Pipeline or reset jedis state .; nested
     exception is redis.clients.jedis.exceptions.JedisDataException: Cannot use Jedis when in Pipeline. Please use Pipeline or reset jedis state .
            at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:64)
            at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:41)
            at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:37)
            at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:37)
            at org.springframework.data.redis.connection.jedis.JedisConnection.convertJedisAccessException(JedisConnection.java:212)
            at org.springframework.data.redis.connection.jedis.JedisConnection.hGetAll(JedisConnection.java:2890)
            at org.springframework.data.redis.connection.DefaultStringRedisConnection.hGetAll(DefaultStringRedisConnection.java:360)
            at org.springframework.data.redis.core.DefaultHashOperations$13.doInRedis(DefaultHashOperations.java:223)
            at org.springframework.data.redis.core.DefaultHashOperations$13.doInRedis(DefaultHashOperations.java:220)
            at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:204)
            at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:166)
            at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:88)
            at org.springframework.data.redis.core.DefaultHashOperations.entries(DefaultHashOperations.java:220)
            ...
    Caused by: redis.clients.jedis.exceptions.JedisDataException: Cannot use Jedis when in Pipeline. Please use Pipeline or reset jedis state .
            at redis.clients.jedis.BinaryJedis.checkIsInMultiOrPipeline(BinaryJedis.java:1761)
            at redis.clients.jedis.BinaryJedis.hgetAll(BinaryJedis.java:1026)
            at org.springframework.data.redis.connection.jedis.JedisConnection.hGetAll(JedisConnection.java:2888)
            ... 14 common frames omitted

0 个答案:

没有答案