[redisson]redis集群模式下,RMapCache报unable to decode data.

2024-07-18 51 views
3

redis集群模式下调用RMapCach.keySet()获取所有key,或者RMapCache.readAllValues()获取所有值。应该能正常返回。

但是,当调用以上两个方法后,报"unable to decode data."

public void myTest(RedissonClient redissonClient) {
     RMapCache<String, User> mapCache = redissonClient.getMapCache("myMapCache");

    mapCache.put("firstUser", new User("redisson1", 5), 1, TimeUnit.MINUTES);
    mapCache.put("secondUser", new User("redisson2", 6), 1, TimeUnit.MINUTES);

    User user = mapCache.get("firstUser");
    System.out.println("get first user--->" + user.toString());

    mapCache.readAllValues().forEach(value -> {
        System.out.println("value-->" + value.toString());
    });

    mapCache.keySet().forEach(key -> {
        System.out.println("all keys-->" + key);
}

如果直接配置spring.redis.host和spring.redis.port来连接redis,以上方法不会报错。但是如果使用spring.redis.cluster.nodes集群模式连接,就会有问题。

Redis version

V3.0.7

Redisson version

V3.9.1

Redisson configuration

spring.redis.password=***** spring.redis.ssl=false spring.redis.timeout=5000 spring.redis.cluster.nodes=192.168.159.129:7001,192.168.159.129:7002,192.168.159.129:7003

回答

0

@@今天发现,跟是否集群好像还没关系。正常运行的程序,我只要修改了getMapCache=("我定义的key")方法中的参数key的值,就会报下面的错误。key我确认是没有使用过的,是我随意输入的值。但是有时候随意输入的值,程序又能正常。实在找不到规律。 @jackygurui

2018-12-11 17:29:22.145 ERROR 4624 --- [isson-netty-1-8] o.r.client.handler.CommandDecoder : Unable to decode data. reply: -MOVED 15886 99.13.219.25:6379 , channel: [id: 0x6518e071, L:/99.12.23.24:49482 - R:99.13.219.23/99.13.219.23:6379], command: CommandData [promise=RedissonPromise [promise=ImmediateEventExecutor$ImmediatePromise@e504f10(incomplete)], command=(EVAL), params=[local insertable = false; local v = redis.call('hget', KEYS[1], ARGV[5]); if v == false then inserta..., 8, MQTaskStatus_Local7989:21993db71f744702bdefdd0f77b6fa3a, redissontimeoutset:{MQTaskStatus_Local7989:21993db71f744702bdefdd0f77b6fa3a}, redissonidleset:{MQTaskStatus_Local7989:21993db71f744702bdefdd0f77b6fa3a}, redisson_map_cache_created:{MQTaskStatus_Local7989:21993db71f744702bdefdd0f77b6fa3a}, redisson_map_cache_updated:{MQTaskStatus_Local7989:21993db71f744702bdefdd0f77b6fa3a}, redissonmap_cache__last_accessset:{MQTaskStatus_Local7989:21993db71f744702bdefdd0f77b6fa3a}, redisson_map_cache_removed:{MQTaskStatus_Local7989:21993db71f744702bdefdd0f77b6fa3a}, {MQTaskStatus_Local7989:21993db71f744702bdefdd0f77b6fa3a}:redisson_options, ...], codec=org.redisson.codec.JsonJacksonCodec]

java.lang.IllegalArgumentException: Redis url should start with redis:// or rediss:// (for SSL connection) at org.redisson.misc.URIBuilder.create(URIBuilder.java:33) ~[redisson-3.9.1.jar:na] at org.redisson.client.RedisRedirectException.(RedisRedirectException.java:36) ~[redisson-3.9.1.jar:na] at org.redisson.client.RedisMovedException.(RedisMovedException.java:28) ~[redisson-3.9.1.jar:na] at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:316) [redisson-3.9.1.jar:na] at org.redisson.client.handler.CommandDecoder.decodeCommand(CommandDecoder.java:128) [redisson-3.9.1.jar:na] at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:108) [redisson-3.9.1.jar:na] at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:502) [netty-codec-4.1.31.Final.jar:4.1.31.Final] at io.netty.handler.codec.ReplayingDecoder.callDecode(ReplayingDecoder.java:366) [netty-codec-4.1.31.Final.jar:4.1.31.Final] at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:278) [netty-codec-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:648) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:583) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:500) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:462) [netty-transport-4.1.31.Final.jar:4.1.31.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897) [netty-common-4.1.31.Final.jar:4.1.31.Final] at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.31.Final.jar:4.1.31.Final] at java.lang.Thread.run(Thread.java:748) [na:1.8.0_162]

9

@KavenSu 这个问题确实是和集群有关,在集群发生了槽点移动的时候会触发该问题。不过这个问题已经被https://github.com/redisson/redisson/commit/21ac3d81c17c0488ee33cb87e5e46b3fb893ec93 修复了,更新一下Redisson的版本就行。

1

@jackygurui 我用的版本是Redisson 3.9.1,这个貌似已经是最新的版本了。您说要更新到哪个版本?

9

@KavenSu 等这周发的版本吧,包含了其他有关MOVE的修复。

6

3.10.0版本已经发布了