From 599dd9542b0f2c353dc6c749d45adb50230e7e2c Mon Sep 17 00:00:00 2001
From: fuderong <2402576196@qq.com>
Date: Sat, 17 Jun 2023 16:12:44 +0800
Subject: [PATCH 1/6] bugfix: fix the timeout is null when the
connectionProxyXA connection is reused
---
.../java/io/seata/rm/datasource/xa/ConnectionProxyXA.java | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/rm-datasource/src/main/java/io/seata/rm/datasource/xa/ConnectionProxyXA.java b/rm-datasource/src/main/java/io/seata/rm/datasource/xa/ConnectionProxyXA.java
index c3162d64908..c1c677e4ecc 100644
--- a/rm-datasource/src/main/java/io/seata/rm/datasource/xa/ConnectionProxyXA.java
+++ b/rm-datasource/src/main/java/io/seata/rm/datasource/xa/ConnectionProxyXA.java
@@ -64,7 +64,7 @@ public class ConnectionProxyXA extends AbstractConnectionProxyXA implements Hold
private volatile Long prepareTime = null;
- private volatile Integer timeout = null;
+ private volatile Integer timeout = Math.max(BRANCH_EXECUTION_TIMEOUT, DefaultValues.DEFAULT_GLOBAL_TRANSACTION_TIMEOUT);
private boolean shouldBeHeld = false;
@@ -89,11 +89,6 @@ public void init() {
if (!currentAutoCommitStatus) {
throw new IllegalStateException("Connection[autocommit=false] as default is NOT supported");
}
- Integer transactionTimeout = RootContext.getTimeout();
- if (transactionTimeout == null) {
- transactionTimeout = DefaultValues.DEFAULT_GLOBAL_TRANSACTION_TIMEOUT;
- }
- timeout = Math.max(BRANCH_EXECUTION_TIMEOUT, transactionTimeout);
} catch (SQLException e) {
throw new RuntimeException(e);
}
@@ -292,7 +287,6 @@ private synchronized void end(int flags) throws XAException, SQLException {
private void cleanXABranchContext() {
branchRegisterTime = null;
prepareTime = null;
- timeout = null;
xaActive = false;
if (!isHeld()) {
xaBranchXid = null;
From 0240cefbf8306bc452d78004421feceaa8cedfcb Mon Sep 17 00:00:00 2001
From: fuderong <2402576196@qq.com>
Date: Sat, 17 Jun 2023 16:21:03 +0800
Subject: [PATCH 2/6] update change log
---
changes/en-us/develop.md | 1 +
changes/zh-cn/develop.md | 1 +
.../main/java/io/seata/rm/datasource/xa/ConnectionProxyXA.java | 2 +-
3 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/changes/en-us/develop.md b/changes/en-us/develop.md
index 677cb622e51..ec5ffaedd65 100644
--- a/changes/en-us/develop.md
+++ b/changes/en-us/develop.md
@@ -37,6 +37,7 @@ Add changes here for all PR submitted to the develop branch.
- [[#5583](https://github.com/seata/seata/pull/5583)] fix grpc interceptor xid unbinding problem
- [[#5602](https://github.com/seata/seata/pull/5602)] fix log in participant transaction role
- [[#5645](https://github.com/seata/seata/pull/5645)] fix oracle insert undolog failed
+- [[#5663](https://github.com/seata/seata/pull/5663)] bugfix: fix the timeout is null when the connectionProxyXA connection is reused
### optimize:
- [[#5208](https://github.com/seata/seata/pull/5208)] optimize throwable getCause once more
diff --git a/changes/zh-cn/develop.md b/changes/zh-cn/develop.md
index 9e537fa1556..a9d4d481d93 100644
--- a/changes/zh-cn/develop.md
+++ b/changes/zh-cn/develop.md
@@ -37,6 +37,7 @@
- [[#5583](https://github.com/seata/seata/pull/5583)] 修复grpc xid 解绑问题
- [[#5602](https://github.com/seata/seata/pull/5602)] 修复participant情况下的重复日志
- [[#5645](https://github.com/seata/seata/pull/5645)] 修复 oracle 插入 undolog 失败问题
+- [[#5663](https://github.com/seata/seata/pull/5663)] 修复connectionProxyXA连接复用时timeout为null
### optimize:
- [[#5208](https://github.com/seata/seata/pull/5208)] 优化多次重复获取Throwable#getCause问题
diff --git a/rm-datasource/src/main/java/io/seata/rm/datasource/xa/ConnectionProxyXA.java b/rm-datasource/src/main/java/io/seata/rm/datasource/xa/ConnectionProxyXA.java
index c1c677e4ecc..de1329c4dfc 100644
--- a/rm-datasource/src/main/java/io/seata/rm/datasource/xa/ConnectionProxyXA.java
+++ b/rm-datasource/src/main/java/io/seata/rm/datasource/xa/ConnectionProxyXA.java
@@ -64,7 +64,7 @@ public class ConnectionProxyXA extends AbstractConnectionProxyXA implements Hold
private volatile Long prepareTime = null;
- private volatile Integer timeout = Math.max(BRANCH_EXECUTION_TIMEOUT, DefaultValues.DEFAULT_GLOBAL_TRANSACTION_TIMEOUT);
+ private static final Integer timeout = Math.max(BRANCH_EXECUTION_TIMEOUT, DefaultValues.DEFAULT_GLOBAL_TRANSACTION_TIMEOUT);
private boolean shouldBeHeld = false;
From 4a162449b09dcaa574049031e3f1330226665e1e Mon Sep 17 00:00:00 2001
From: fuderong <2402576196@qq.com>
Date: Sun, 18 Jun 2023 16:44:40 +0800
Subject: [PATCH 3/6] check pass
---
.../java/io/seata/rm/datasource/xa/ConnectionProxyXA.java | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/rm-datasource/src/main/java/io/seata/rm/datasource/xa/ConnectionProxyXA.java b/rm-datasource/src/main/java/io/seata/rm/datasource/xa/ConnectionProxyXA.java
index de1329c4dfc..c229f782a36 100644
--- a/rm-datasource/src/main/java/io/seata/rm/datasource/xa/ConnectionProxyXA.java
+++ b/rm-datasource/src/main/java/io/seata/rm/datasource/xa/ConnectionProxyXA.java
@@ -26,7 +26,6 @@
import io.seata.common.DefaultValues;
import io.seata.common.util.StringUtils;
import io.seata.config.ConfigurationFactory;
-import io.seata.core.context.RootContext;
import io.seata.core.exception.TransactionException;
import io.seata.core.model.BranchStatus;
import io.seata.core.model.BranchType;
@@ -64,7 +63,7 @@ public class ConnectionProxyXA extends AbstractConnectionProxyXA implements Hold
private volatile Long prepareTime = null;
- private static final Integer timeout = Math.max(BRANCH_EXECUTION_TIMEOUT, DefaultValues.DEFAULT_GLOBAL_TRANSACTION_TIMEOUT);
+ private static final Integer TIMEOUT = Math.max(BRANCH_EXECUTION_TIMEOUT, DefaultValues.DEFAULT_GLOBAL_TRANSACTION_TIMEOUT);
private boolean shouldBeHeld = false;
@@ -294,7 +293,7 @@ private void cleanXABranchContext() {
}
private void checkTimeout(Long now) throws XAException {
- if (now - branchRegisterTime > timeout) {
+ if (now - branchRegisterTime > TIMEOUT) {
xaRollback(xaBranchXid);
throw new XAException("XA branch timeout error");
}
From a62a94cfbf6ce0be3aa4fc30b647de37e59bfdfa Mon Sep 17 00:00:00 2001
From: fuderong <2402576196@qq.com>
Date: Sat, 14 Oct 2023 14:08:33 +0800
Subject: [PATCH 4/6] add sentinelPassword
---
.../java/io/seata/common/ConfigurationKeys.java | 5 +++++
dependencies/pom.xml | 2 +-
script/config-center/config.txt | 1 +
.../server/storage/redis/JedisPooledFactory.java | 13 +++++--------
4 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/common/src/main/java/io/seata/common/ConfigurationKeys.java b/common/src/main/java/io/seata/common/ConfigurationKeys.java
index 037ac246f4b..8a584b2b8b9 100644
--- a/common/src/main/java/io/seata/common/ConfigurationKeys.java
+++ b/common/src/main/java/io/seata/common/ConfigurationKeys.java
@@ -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.
*/
diff --git a/dependencies/pom.xml b/dependencies/pom.xml
index e33cf878db9..6b608560920 100644
--- a/dependencies/pom.xml
+++ b/dependencies/pom.xml
@@ -92,7 +92,7 @@
0.2.0-RC2
- 3.2.0
+ 3.8.0
diff --git a/script/config-center/config.txt b/script/config-center/config.txt
index 8e7065e8ef7..38f49bff14a 100644
--- a/script/config-center/config.txt
+++ b/script/config-center/config.txt
@@ -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
diff --git a/server/src/main/java/io/seata/server/storage/redis/JedisPooledFactory.java b/server/src/main/java/io/seata/server/storage/redis/JedisPooledFactory.java
index d3d1a442eed..45fc28e336f 100644
--- a/server/src/main/java/io/seata/server/storage/redis/JedisPooledFactory.java
+++ b/server/src/main/java/io/seata/server/storage/redis/JedisPooledFactory.java
@@ -27,11 +27,7 @@
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.*;
import static io.seata.common.DefaultValues.DEFAULT_REDIS_MAX_IDLE;
import static io.seata.common.DefaultValues.DEFAULT_REDIS_MAX_TOTAL;
@@ -59,7 +55,7 @@ public class JedisPooledFactory {
/**
* get the RedisPool instance (singleton)
- *
+ *
* @return redisPool
*/
public static JedisPoolAbstract getJedisPoolInstance(JedisPoolAbstract... jedisPools) {
@@ -98,7 +94,8 @@ public static JedisPoolAbstract getJedisPoolInstance(JedisPoolAbstract... jedisP
Set 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;
@@ -121,7 +118,7 @@ public static JedisPoolAbstract getJedisPoolInstance(JedisPoolAbstract... jedisP
/**
* get an instance of Jedis (connection) from the connection pool
- *
+ *
* @return jedis
*/
public static Jedis getJedisInstance() {
From 7c49f4da52da2fc8b5564e32147a62145049b9a7 Mon Sep 17 00:00:00 2001
From: fuderong <2402576196@qq.com>
Date: Sat, 14 Oct 2023 14:25:02 +0800
Subject: [PATCH 5/6] add changes
---
changes/en-us/develop.md | 2 +-
changes/zh-cn/develop.md | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/changes/en-us/develop.md b/changes/en-us/develop.md
index 0ca04a47112..3138c749979 100644
--- a/changes/en-us/develop.md
+++ b/changes/en-us/develop.md
@@ -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 problem 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
diff --git a/changes/zh-cn/develop.md b/changes/zh-cn/develop.md
index fbf2e7de30b..dbcc7a3e782 100644
--- a/changes/zh-cn/develop.md
+++ b/changes/zh-cn/develop.md
@@ -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)] 一些小的语法优化
From 8cb7ff0bb5024f0544389746089b39c63b1c7837 Mon Sep 17 00:00:00 2001
From: PeppaO <2402576196@qq.com>
Date: Tue, 17 Oct 2023 13:28:53 +0800
Subject: [PATCH 6/6] bugfix
---
changes/en-us/develop.md | 2 +-
.../properties/server/store/StoreRedisProperties.java | 11 +++++++++++
.../server/storage/redis/JedisPooledFactory.java | 7 ++++++-
server/src/main/resources/application.example.yml | 1 +
4 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/changes/en-us/develop.md b/changes/en-us/develop.md
index d8dd4ce4980..4716fa2dddf 100644
--- a/changes/en-us/develop.md
+++ b/changes/en-us/develop.md
@@ -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 problem of missing sentinel password in store redis mode
+- [[#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
diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/main/java/io/seata/spring/boot/autoconfigure/properties/server/store/StoreRedisProperties.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/main/java/io/seata/spring/boot/autoconfigure/properties/server/store/StoreRedisProperties.java
index c6420d84db7..d42a31609ac 100644
--- a/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/main/java/io/seata/spring/boot/autoconfigure/properties/server/store/StoreRedisProperties.java
+++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/main/java/io/seata/spring/boot/autoconfigure/properties/server/store/StoreRedisProperties.java
@@ -142,6 +142,8 @@ public static class Sentinel {
*/
private String sentinelHosts;
+ private String sentinelPassword;
+
public String getMasterName() {
return masterName;
}
@@ -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;
+ }
}
}
diff --git a/server/src/main/java/io/seata/server/storage/redis/JedisPooledFactory.java b/server/src/main/java/io/seata/server/storage/redis/JedisPooledFactory.java
index 45fc28e336f..8512145c1d8 100644
--- a/server/src/main/java/io/seata/server/storage/redis/JedisPooledFactory.java
+++ b/server/src/main/java/io/seata/server/storage/redis/JedisPooledFactory.java
@@ -27,7 +27,12 @@
import io.seata.core.constants.ConfigurationKeys;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import redis.clients.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;
diff --git a/server/src/main/resources/application.example.yml b/server/src/main/resources/application.example.yml
index 211c95c5e70..30679032ddb 100644
--- a/server/src/main/resources/application.example.yml
+++ b/server/src/main/resources/application.example.yml
@@ -179,6 +179,7 @@ seata:
sentinel:
master-name:
sentinel-hosts:
+ sentinel-password:
metrics:
enabled: false
registry-type: compact