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

bugfix: fix the issue of missing sentinel password in store redis mode #5931

Merged
merged 8 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion changes/en-us/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Add changes here for all PR submitted to the develop branch.
### bugfix:
- [[#5833](https://github.com/seata/seata/pull/5833)] bugfix: fix TC retry rollback wrongly, after the XA transaction fail and rollback
- [[#5884](https://github.com/seata/seata/pull/5884)] fix dm escaped characters for upper and lower case column names

- [[#5931](https://github.com/seata/seata/pull/5931)] fix the issue of missing sentinel password in store redis mode
### optimize:
- [[#5866](https://github.com/seata/seata/pull/5866)] some minor syntax optimization
- [[#5889](https://github.com/seata/seata/pull/5889)] remove dependency without license
Expand Down
1 change: 1 addition & 0 deletions changes/zh-cn/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### bugfix:
- [[#5833](https://github.com/seata/seata/pull/5833)] bugfix: 修复当 XA 事务失败回滚后,TC 还会继续重试回滚的问题
- [[#5884](https://github.com/seata/seata/pull/5884)] 修复达梦前后镜像查询列名都加了引号导致sql异常的问题
- [[#5931](https://github.com/seata/seata/pull/5931)] 修复存储redis哨兵模式下哨兵密码缺失的问题

### optimize:
- [[#5866](https://github.com/seata/seata/pull/5866)] 一些小的语法优化
Expand Down
5 changes: 5 additions & 0 deletions common/src/main/java/io/seata/common/ConfigurationKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,11 @@ public interface ConfigurationKeys {
*/
String STORE_REDIS_SENTINEL_HOST = STORE_REDIS_SENTINEL_PREFIX + "sentinelHosts";

/**
* STORE_REDIS_SENTINEL_PASSWORD.
*/
String STORE_REDIS_SENTINEL_PASSWORD = STORE_REDIS_SENTINEL_PREFIX + "sentinelPassword";

/**
* The constant CLIENT_DEGRADE_CHECK_PERIOD.
*/
Expand Down
2 changes: 1 addition & 1 deletion dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<kafka-appender.version>0.2.0-RC2</kafka-appender.version>

<!-- redis -->
<jedis.version>3.2.0</jedis.version>
<jedis.version>3.8.0</jedis.version>

<!-- # for database -->
<!-- db -->
Expand Down
1 change: 1 addition & 0 deletions script/config-center/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ store.redis.single.host=127.0.0.1
store.redis.single.port=6379
store.redis.sentinel.masterName=
store.redis.sentinel.sentinelHosts=
store.redis.sentinel.sentinelPassword=
store.redis.maxConn=10
store.redis.minConn=1
store.redis.maxTotal=100
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ public static class Sentinel {
*/
private String sentinelHosts;

private String sentinelPassword;

public String getMasterName() {
return masterName;
}
Expand All @@ -159,5 +161,14 @@ public Sentinel setSentinelHosts(String sentinelHosts) {
this.sentinelHosts = sentinelHosts;
return this;
}

public String getSentinelPassword() {
return sentinelPassword;
}

public Sentinel setSentinelPassword(String sentinelPassword) {
this.sentinelPassword = sentinelPassword;
return this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@
import io.seata.core.constants.ConfigurationKeys;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolAbstract;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.JedisSentinelPool;
import redis.clients.jedis.Protocol;
import redis.clients.jedis.Jedis;

import static io.seata.common.DefaultValues.DEFAULT_REDIS_MAX_IDLE;
import static io.seata.common.DefaultValues.DEFAULT_REDIS_MAX_TOTAL;
Expand Down Expand Up @@ -59,7 +60,7 @@ public class JedisPooledFactory {

/**
* get the RedisPool instance (singleton)
*
*
* @return redisPool
*/
public static JedisPoolAbstract getJedisPoolInstance(JedisPoolAbstract... jedisPools) {
Expand Down Expand Up @@ -98,7 +99,8 @@ public static JedisPoolAbstract getJedisPoolInstance(JedisPoolAbstract... jedisP
Set<String> sentinels = new HashSet<>(SENTINEL_HOST_NUMBER);
String[] sentinelHosts = CONFIGURATION.getConfig(ConfigurationKeys.STORE_REDIS_SENTINEL_HOST).split(",");
Arrays.asList(sentinelHosts).forEach(sentinelHost -> sentinels.add(sentinelHost));
tempJedisPool = new JedisSentinelPool(masterName, sentinels, poolConfig, 60000, password, CONFIGURATION.getInt(ConfigurationKeys.STORE_REDIS_DATABASE, DATABASE));
tempJedisPool = new JedisSentinelPool(masterName, sentinels, poolConfig, 60000, 60000, password, CONFIGURATION.getInt(ConfigurationKeys.STORE_REDIS_DATABASE, DATABASE),
null, Protocol.DEFAULT_TIMEOUT, Protocol.DEFAULT_TIMEOUT, CONFIGURATION.getConfig(ConfigurationKeys.STORE_REDIS_SENTINEL_PASSWORD), null);
} else if (mode.equals(ConfigurationKeys.REDIS_SINGLE_MODE)) {
String host = CONFIGURATION.getConfig(ConfigurationKeys.STORE_REDIS_SINGLE_HOST);
host = StringUtils.isBlank(host) ? CONFIGURATION.getConfig(ConfigurationKeys.STORE_REDIS_HOST, HOST) : host;
Expand All @@ -121,7 +123,7 @@ public static JedisPoolAbstract getJedisPoolInstance(JedisPoolAbstract... jedisP

/**
* get an instance of Jedis (connection) from the connection pool
*
*
* @return jedis
*/
public static Jedis getJedisInstance() {
Expand Down