Redisson分布式可重入锁异常

Redisson distributed reentrant Lock Exception

我正在使用 redis 3.0.6(4 节点集群)和 redisson 版本 2.2.5。 有时,当我尝试锁定一个键时,会出现以下异常: 我的代码:

    String key = String.valueOf("425011000000151");
    RLock lc = client.getLock(key);
    lc.lock(lockTime,TimeUnit.MILLISECONDS);
    System.out.println("Got key: " + key);
    lc.unlock();

错误:

org.redisson.client.RedisException: ERR Error running script (call to f_93cfc048f82624d1670a310aa0ad58918c0824a5): @user_script:1: WRONGTYPE Operation against a key holding the wrong kind of value . channel: [id: 0x6280a1db, /10.135.50.64:59377 => /10.10.25.183:7002] command: CommandData [promise=DefaultPromise@79d4be49(incomplete), command=(EVAL), params=[if (redis.call('exists', KEYS[1]) == 0) then redis.call('publish', KEYS[2], ARGV[1]); return 1; end;if (redis.call('hexists', KEYS[1], ARGV[3]) == 0) then return nil;end; local counter = redis.call('hincrby', KEYS[1], ARGV[3], -1); if (counter > 0) then redis.call('pexpire', KEYS[1], ARGV[2]); return 0; else redis.call('del', KEYS[1]); redis.call('publish', KEYS[2], ARGV[1]); return 1; end; return nil;, 2, 425011000000151, redisson_lock__channel__{425011000000151}, 0, 30000, 15f636a8-4b5b-4351-9f55-14ade7a2cbd4:359], 

跟踪:

at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:190) at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:105) at io.netty.handler.codec.ReplayingDecoder.callDecode(ReplayingDecoder.java:370) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:244) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) at io.netty.util.concurrent.SingleThreadEventExecutor.run(SingleThreadEventExecutor.java:112) at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137) at java.lang.Thread.run(Thread.java:744)

我从经济衰退问题论坛得到了答案

https://github.com/mrniko/redisson/issues/480