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

Dubbo 3.2 中 redis是cluster模式时,不支持password #12233

Closed
goto456 opened this issue May 5, 2023 · 3 comments
Closed

Dubbo 3.2 中 redis是cluster模式时,不支持password #12233

goto456 opened this issue May 5, 2023 · 3 comments
Labels
type/bug Bugs to being fixed

Comments

@goto456
Copy link
Contributor

goto456 commented May 5, 2023

Environment

  • Dubbo version: 3.2.0 或 3.0.12
  • Java version: 1.8

RedisMetadataReport类中当redis是cluster模式时,password并没有起作用,源码中password未初始化,为null,导致报了如下错误:

Caused by: redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required.
	at redis.clients.jedis.Protocol.processError(Protocol.java:127)
	at redis.clients.jedis.Protocol.process(Protocol.java:161)
	at redis.clients.jedis.Protocol.read(Protocol.java:215)
	at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:340)
	at redis.clients.jedis.Connection.getRawObjectMultiBulkReply(Connection.java:285)
	at redis.clients.jedis.Connection.getObjectMultiBulkReply(Connection.java:291)
	at redis.clients.jedis.Jedis.clusterSlots(Jedis.java:3376)
	at redis.clients.jedis.JedisClusterInfoCache.discoverClusterNodesAndSlots(JedisClusterInfoCache.java:54)
	at redis.clients.jedis.JedisClusterConnectionHandler.initializeSlotsCache(JedisClusterConnectionHandler.java:39)
	at redis.clients.jedis.JedisClusterConnectionHandler.<init>(JedisClusterConnectionHandler.java:17)
	at redis.clients.jedis.JedisSlotBasedConnectionHandler.<init>(JedisSlotBasedConnectionHandler.java:24)
	at redis.clients.jedis.BinaryJedisCluster.<init>(BinaryJedisCluster.java:54)
	at redis.clients.jedis.JedisCluster.<init>(JedisCluster.java:93)
	at org.apache.dubbo.metadata.store.redis.RedisMetadataReport.storeMetadataInCluster(RedisMetadataReport.java:133)

RedisMetadataReport中相关代码:

public RedisMetadataReport(URL url) {
        super(url);
        timeout = url.getParameter(TIMEOUT_KEY, DEFAULT_TIMEOUT);
        if (url.getParameter(CLUSTER_KEY, false)) {
            jedisClusterNodes = new HashSet<>();
            List<URL> urls = url.getBackupUrls();
            for (URL tmpUrl : urls) {
                jedisClusterNodes.add(new HostAndPort(tmpUrl.getHost(), tmpUrl.getPort()));
            }
        } else {
            int database = url.getParameter(REDIS_DATABASE_KEY, 0);
            pool = new JedisPool(new JedisPoolConfig(), url.getHost(), url.getPort(), timeout, url.getPassword(), database);
        }
    }

// 此处passowrd为空,并未从url中获取并进行初始化
private void storeMetadataInCluster(BaseMetadataIdentifier metadataIdentifier, String v) {
        try (JedisCluster jedisCluster = new JedisCluster(jedisClusterNodes, timeout, timeout, 2, password, new GenericObjectPoolConfig())) {
            jedisCluster.set(metadataIdentifier.getIdentifierKey() + META_DATA_STORE_TAG, v);
        } catch (Throwable e) {
            String msg = "Failed to put " + metadataIdentifier + " to redis cluster " + v + ", cause: " + e.getMessage();
            logger.error(TRANSPORT_FAILED_RESPONSE, "", "", msg, e);
            throw new RpcException(msg, e);
        }
    }
@goto456 goto456 added the type/bug Bugs to being fixed label May 5, 2023
@AlbumenJ
Copy link
Member

AlbumenJ commented May 5, 2023

Would you please help to fix it?

@goto456
Copy link
Contributor Author

goto456 commented May 6, 2023

Would you please help to fix it?

OK,let me fix it.

@AlbumenJ
Copy link
Member

AlbumenJ commented May 7, 2023

Fixed in #12240

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Bugs to being fixed
Projects
Status: Done
Development

No branches or pull requests

2 participants