ERR EXEC without MULTI - spring redis+jedis

送分小仙女□ 提交于 2019-12-12 02:04:55

问题


I meet with exception during a transactional operation with spring-data-redis

RedisTemplate<String,Object> cartCache;

public void create(final Cartline cartline) {
  Object txResults = cartCache.execute(new SessionCallback<List>() {
    public List execute(RedisOperations operations) throws DataAccessException {
      String cartId = cartline.getMemberId();
      String cartlineId = cartline.getCartlineId();
      operations.multi();    
      ......           
      return operations.exec();
    }
  });
}

redis.clients.jedis.exceptions.JedisDataException: ERR EXEC without MULTI
    at redis.clients.jedis.Protocol.processError(Protocol.java:115)
    at redis.clients.jedis.Protocol.process(Protocol.java:133)
    at redis.clients.jedis.Protocol.read(Protocol.java:202)
    at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:285)
    at redis.clients.jedis.Connection.getRawObjectMultiBulkReply(Connection.java:230)
    at redis.clients.jedis.Connection.getObjectMultiBulkReply(Connection.java:236)
    at redis.clients.jedis.Transaction.exec(Transaction.java:38)
    at org.springframework.data.redis.connection.jedis.JedisConnection.exec(JedisConnection.java:738)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.springframework.data.redis.core.CloseSuppressingInvocationHandler.invoke(CloseSuppressingInvocationHandler.java:57)
    at com.sun.proxy.$Proxy512.exec(Unknown Source)
    at org.springframework.data.redis.core.RedisTemplate$3.doInRedis(RedisTemplate.java:593)
    at org.springframework.data.redis.core.RedisTemplate$3.doInRedis(RedisTemplate.java:591)
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:190)
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:152)
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:140)
    at org.springframework.data.redis.core.RedisTemplate.execRaw(RedisTemplate.java:591)
    at org.springframework.data.redis.core.RedisTemplate.exec(RedisTemplate.java:578)
    at com.znova.stone.cart.repository.impl.CartCacheImpl$1.execute(CartCacheImpl.java:51)
    at com.znova.stone.cart.repository.impl.CartCacheImpl$1.execute(CartCacheImpl.java:1)
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:217)

I read this post ERR EXEC without MULTI - Jedis which indicates a multi with exec, I also have redisTemplate.setEnableTransactionSupport(true); enabled, the error stood still.

I removed operation logic within the multi-exec block, I found there is no difference whatever is there, the exception happens event with a zero-operation block.


回答1:


I had this same problem and fixed it by updating spring-data-redis from 1.4.2.RELEASE to 1.5.2.RELEASE.



来源:https://stackoverflow.com/questions/27699007/err-exec-without-multi-spring-redisjedis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!