Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

升级2.7.0版本后 RedisURI为null #707

Open
qewsd opened this issue Aug 26, 2022 · 16 comments
Open

升级2.7.0版本后 RedisURI为null #707

qewsd opened this issue Aug 26, 2022 · 16 comments

Comments

@qewsd
Copy link

qewsd commented Aug 26, 2022

image
image
image
之前2.6.7版本一直没事,升级2.7.0后报错

@qewsd
Copy link
Author

qewsd commented Aug 26, 2022

他是读取到配置表的,发现RedisLettuceAutoConfiguration创建的时候就没有create(url)跟2.6版本有区别,不清楚是否是这块的影响

@areyouok
Copy link
Collaborator

你看看是不试 @ 字符需要转义

@qewsd
Copy link
Author

qewsd commented Aug 27, 2022

你看看是不试 @ 字符需要转义

image
他能读出来呀,大佬

@qewsd
Copy link
Author

qewsd commented Aug 27, 2022

你看看是不试 @ 字符需要转义

image
image
我用不带密码的方式请求,发现还是一样的,同样配置2.6.7没有任何问题

@areyouok
Copy link
Collaborator

RedisLettuceAutoConfiguration这个类的构造方式变了,但是你可以直接拿connection或command:

    @Bean
    @DependsOn(RedisLettuceAutoConfiguration.AUTO_INIT_BEAN_NAME)
    public LettuceFactory redisCon() {
        return new LettuceFactory("remote.default", StatefulRedisConnection.class);
    }

    @Bean
    @DependsOn(RedisLettuceAutoConfiguration.AUTO_INIT_BEAN_NAME)
    public LettuceFactory redisCommand() {
        return new LettuceFactory("remote.default", RedisCommands.class);
    }

    @Bean
    @DependsOn(RedisLettuceAutoConfiguration.AUTO_INIT_BEAN_NAME)
    public LettuceFactory redisCommand2() {
        return new LettuceFactory("remote.default", RedisAsyncCommands.class);
    }

@qewsd
Copy link
Author

qewsd commented Aug 27, 2022

StatefulRedisConnection

image
之前用过你这个方法直接拿但是会报这个错,所以才这样拿的

@qewsd
Copy link
Author

qewsd commented Aug 27, 2022

RedisLettuceAutoConfiguration这个类的构造方式变了,但是你可以直接拿connection或command:

    @Bean
    @DependsOn(RedisLettuceAutoConfiguration.AUTO_INIT_BEAN_NAME)
    public LettuceFactory redisCon() {
        return new LettuceFactory("remote.default", StatefulRedisConnection.class);
    }

    @Bean
    @DependsOn(RedisLettuceAutoConfiguration.AUTO_INIT_BEAN_NAME)
    public LettuceFactory redisCommand() {
        return new LettuceFactory("remote.default", RedisCommands.class);
    }

    @Bean
    @DependsOn(RedisLettuceAutoConfiguration.AUTO_INIT_BEAN_NAME)
    public LettuceFactory redisCommand2() {
        return new LettuceFactory("remote.default", RedisAsyncCommands.class);
    }

用你这个方法拿的话不管2.6.7还是2.7.0,使用redisCommands都是直接报错的

@qewsd
Copy link
Author

qewsd commented Aug 27, 2022

RedisLettuceAutoConfiguration这个类的构造方式变了,但是你可以直接拿connection或command:

    @Bean
    @DependsOn(RedisLettuceAutoConfiguration.AUTO_INIT_BEAN_NAME)
    public LettuceFactory redisCon() {
        return new LettuceFactory("remote.default", StatefulRedisConnection.class);
    }

    @Bean
    @DependsOn(RedisLettuceAutoConfiguration.AUTO_INIT_BEAN_NAME)
    public LettuceFactory redisCommand() {
        return new LettuceFactory("remote.default", RedisCommands.class);
    }

    @Bean
    @DependsOn(RedisLettuceAutoConfiguration.AUTO_INIT_BEAN_NAME)
    public LettuceFactory redisCommand2() {
        return new LettuceFactory("remote.default", RedisAsyncCommands.class);
    }

image
image
image
这是代码和配置

@areyouok
Copy link
Collaborator

我知道了,jetcache给的connection和commands,设置了JetCacheCodec,所以key和value只能接收字节数组。

现在构造方式已经变了,所以jetcache给的RedisClient里面没有uri,它是这样的:

                    client = RedisClient.create();
                    ((RedisClient) client).setOptions(ClientOptions.builder().
                            disconnectedBehavior(ClientOptions.DisconnectedBehavior.REJECT_COMMANDS).build());
                    StatefulRedisMasterReplicaConnection c = MasterReplica.connect(
                            (RedisClient) client, new JetCacheCodec(), uriList);

这个不好解决,你自己弄一个connection/command吧。或者用jetcache提供的connection/command,但是输入和输出都要是字节数组。具体可以看RedisLettuceAutoConfiguration这个类。

@qewsd
Copy link
Author

qewsd commented Aug 31, 2022

我知道了,jetcache给的connection和commands,设置了JetCacheCodec,所以key和value只能接收字节数组。

现在构造方式已经变了,所以jetcache给的RedisClient里面没有uri,它是这样的:

                    client = RedisClient.create();
                    ((RedisClient) client).setOptions(ClientOptions.builder().
                            disconnectedBehavior(ClientOptions.DisconnectedBehavior.REJECT_COMMANDS).build());
                    StatefulRedisMasterReplicaConnection c = MasterReplica.connect(
                            (RedisClient) client, new JetCacheCodec(), uriList);

这个不好解决,你自己弄一个connection/command吧。或者用jetcache提供的connection/command,但是输入和输出都要是字节数组。具体可以看RedisLettuceAutoConfiguration这个类。

image
为啥都缺class类了?2.7以后使用kryo序列化转换需要引入包了吗

@areyouok
Copy link
Collaborator

看一下兼容性说明文档,2.7同时支持kryo4.0和5.0,但是需要你自己在pom中引入,kryo4.0和5.0完全不兼容

@qewsd
Copy link
Author

qewsd commented Aug 31, 2022

看一下兼容性说明文档,2.7同时支持kryo4.0和5.0,但是需要你自己在pom中引入,kryo4.0和5.0完全不兼容

好的……2.7确实更新太大了,大佬我这样用你这个组件3年多了,你这是大更新呀,我之前通过你给的接口实现了一套二级缓存更新时更新本地缓存的东西,你这终于出自带的了呀

@areyouok
Copy link
Collaborator

如果都兼容就不用改版本号了。

@qewsd
Copy link
Author

qewsd commented Oct 11, 2022

我知道了,jetcache给的connection和commands,设置了JetCacheCodec,所以key和value只能接收字节数组。

现在构造方式已经变了,所以jetcache给的RedisClient里面没有uri,它是这样的:

                    client = RedisClient.create();
                    ((RedisClient) client).setOptions(ClientOptions.builder().
                            disconnectedBehavior(ClientOptions.DisconnectedBehavior.REJECT_COMMANDS).build());
                    StatefulRedisMasterReplicaConnection c = MasterReplica.connect(
                            (RedisClient) client, new JetCacheCodec(), uriList);

这个不好解决,你自己弄一个connection/command吧。或者用jetcache提供的connection/command,但是输入和输出都要是字节数组。具体可以看RedisLettuceAutoConfiguration这个类。

你好使用jetcache提供的connection/command时,连接一段时间后,动不动报org.springframework.web.util.NestedServletException: Request processing failed; nested exception is io.netty.handler.codec.EncoderException: Cannot encode command. Please close the connection as the connection state may be out of sync. 然后所有jetcahce的缓存全报错,只能重启然后好一段时间,有时候也动不动重连redis,请问怎么回事呢

@qewsd
Copy link
Author

qewsd commented Oct 13, 2022

我知道了,jetcache给的connection和commands,设置了JetCacheCodec,所以key和value只能接收字节数组。
现在构造方式已经变了,所以jetcache给的RedisClient里面没有uri,它是这样的:

                    client = RedisClient.create();
                    ((RedisClient) client).setOptions(ClientOptions.builder().
                            disconnectedBehavior(ClientOptions.DisconnectedBehavior.REJECT_COMMANDS).build());
                    StatefulRedisMasterReplicaConnection c = MasterReplica.connect(
                            (RedisClient) client, new JetCacheCodec(), uriList);

这个不好解决,你自己弄一个connection/command吧。或者用jetcache提供的connection/command,但是输入和输出都要是字节数组。具体可以看RedisLettuceAutoConfiguration这个类。

你好使用jetcache提供的connection/command时,连接一段时间后,动不动报org.springframework.web.util.NestedServletException: Request processing failed; nested exception is io.netty.handler.codec.EncoderException: Cannot encode command. Please close the connection as the connection state may be out of sync. 然后所有jetcahce的缓存全报错,只能重启然后好一段时间,有时候也动不动重连redis,请问怎么回事呢

发现问题了,在高并发环境下可能有些值没获取到传入了null,就报这个错了,这个数据格式居然连null也不支持,lettuce居然一报错就中断也是醉了,大佬能不能支持一下除了字节数组以外的格式呢

@areyouok
Copy link
Collaborator

这无法设计,不行你自己搞个连接用了。

lettuce是单连接复用的,没有连接池,编解码出错,连接就挂了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants