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

optimize: RM TM startup connect server fail fast #6004

Merged
merged 40 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
69e4497
optimize: RM TM startup connect server fail fast
jsbxyyx Nov 7, 2023
d089244
add change
jsbxyyx Nov 7, 2023
89186d2
judge thread name
jsbxyyx Nov 9, 2023
7b01e32
Merge branch '2.x' of github.com:seata/seata into check2
jsbxyyx Nov 10, 2023
3e20f87
do reconnect
jsbxyyx Nov 10, 2023
34be22e
revert
jsbxyyx Nov 10, 2023
99562b7
Merge branch '2.x' into check2
funky-eyes Nov 11, 2023
9203558
Merge branch '2.x' into check2
jsbxyyx Nov 13, 2023
303e60e
Merge branch '2.x' into check2
funky-eyes Nov 27, 2023
849d767
Merge branch '2.x' into check2
funky-eyes Nov 28, 2023
232f187
Merge branch '2.x' into check2
funky-eyes Nov 29, 2023
e6a7e01
Merge branch '2.x' of github.com:seata/seata into check2
jsbxyyx Dec 1, 2023
2197068
add error log
jsbxyyx Dec 1, 2023
f9e88ff
Merge branch '2.x' into check2
funky-eyes Dec 5, 2023
2789bb1
Merge branch '2.x' into check2
jsbxyyx Dec 7, 2023
acc2ba6
fix: reviews
jsbxyyx Dec 7, 2023
0c62533
fix: available list empty
jsbxyyx Dec 11, 2023
16a2837
Merge branch '2.x' into check2
funky-eyes Dec 16, 2023
b7fd7af
fix reviews
jsbxyyx Dec 18, 2023
525e38e
Merge branch 'check2' of github.com:jsbxyyx/seata into check2
jsbxyyx Dec 18, 2023
e549797
Merge branch '2.x' into check2
funky-eyes Dec 18, 2023
ad32f72
fail fast default true
jsbxyyx Dec 22, 2023
04ae7d3
Merge branch '2.x' into check2
jsbxyyx Dec 22, 2023
a6e5276
fix: test
jsbxyyx Dec 22, 2023
583b257
Merge branch 'check2' of github.com:jsbxyyx/seata into check2
jsbxyyx Dec 22, 2023
a144b0c
fix test
jsbxyyx Dec 22, 2023
16bfd7f
add test
jsbxyyx Jan 4, 2024
f4d33a2
test
funky-eyes Jan 4, 2024
6814bc8
test
funky-eyes Jan 4, 2024
8fde8ec
test
funky-eyes Jan 4, 2024
8c32c3f
test
funky-eyes Jan 4, 2024
a78e7b1
test
funky-eyes Jan 4, 2024
c9ca778
test
funky-eyes Jan 4, 2024
7a5886d
test
funky-eyes Jan 4, 2024
e054f4e
update changes md
jsbxyyx Jan 4, 2024
c9a3357
Merge branch '2.x' into check2
jsbxyyx Jan 4, 2024
9062be8
Update changes/en-us/2.x.md
funky-eyes Jan 4, 2024
e5bb5ee
Update core/src/test/java/io/seata/core/rpc/netty/TmNettyClientTest.java
funky-eyes Jan 4, 2024
af9db4d
Update core/src/test/java/io/seata/core/rpc/netty/RmNettyClientTest.java
funky-eyes Jan 4, 2024
0893fca
Update core/src/test/java/io/seata/core/rpc/netty/TmNettyClientTest.java
funky-eyes Jan 4, 2024
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
1 change: 1 addition & 0 deletions changes/en-us/2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ The version is updated as follows:
- [[#5938](https://github.com/seata/seata/pull/5938)] support jmx port in seata
- [[#5951](https://github.com/seata/seata/pull/5951)] remove un support config in jdk17
- [[#5959](https://github.com/seata/seata/pull/5959)] modify code style and remove unused import
- [[#6004](https://github.com/seata/seata/pull/6004)] optimize RM TM startup connect server fail fast

### security:
- [[#5642](https://github.com/seata/seata/pull/5642)] add Hessian Serializer WhiteDenyList
Expand Down
1 change: 1 addition & 0 deletions changes/zh-cn/2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单
- [[#5938](https://github.com/seata/seata/pull/5938)] 支持 jmx 监控配置
- [[#5951](https://github.com/seata/seata/pull/5951)] 删除在 jdk17 中不支持的配置项
- [[#5959](https://github.com/seata/seata/pull/5959)] 修正代码风格问题及去除无用的类引用
- [[#6004](https://github.com/seata/seata/pull/6004)] 优化RM,TM连接server快速失败


### security:
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 @@ -638,6 +638,11 @@ public interface ConfigurationKeys {
*/
String ENABLE_TM_CLIENT_BATCH_SEND_REQUEST = TRANSPORT_PREFIX + "enableTmClientBatchSendRequest";

/**
* The constant ENABLE_CLIENT_CHANNEL_CHECK_FAIL_FAST
*/
String ENABLE_CLIENT_CHANNEL_CHECK_FAIL_FAST = TRANSPORT_PREFIX + "enableClientChannelCheckFailFast";

/**
* The constant ENABLE_RM_CLIENT_BATCH_SEND_REQUEST
*/
Expand Down
2 changes: 2 additions & 0 deletions common/src/main/java/io/seata/common/DefaultValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public interface DefaultValues {
boolean DEFAULT_ENABLE_RM_CLIENT_BATCH_SEND_REQUEST = true;
boolean DEFAULT_ENABLE_TC_SERVER_BATCH_SEND_RESPONSE = false;

boolean DEFAULT_CLIENT_CHANNEL_CHECK_FAIL_FAST = false;
jsbxyyx marked this conversation as resolved.
Show resolved Hide resolved

String DEFAULT_BOSS_THREAD_PREFIX = "NettyBoss";
String DEFAULT_NIO_WORKER_THREAD_PREFIX = "NettyServerNIOWorker";
String DEFAULT_EXECUTOR_THREAD_PREFIX = "NettyServerBizHandler";
Expand Down
28 changes: 28 additions & 0 deletions common/src/main/java/io/seata/common/util/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -373,4 +374,31 @@ public static boolean hasUpperCase(String str) {
return false;
}

public static String join(Iterator iterator, String separator) {
if (iterator == null) {
return null;
}
if (!iterator.hasNext()) {
return EMPTY;
}
Object first = iterator.next();
if (!iterator.hasNext()) {
return first == null ? "" : first.toString();
}
StringBuilder builder = new StringBuilder(256);
if (first != null) {
builder.append(first);
}
while (iterator.hasNext()) {
if (separator != null) {
builder.append(separator);
}
Object obj = iterator.next();
if (obj != null) {
builder.append(obj);
}
}
return builder.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,13 @@ public abstract class AbstractNettyRemotingClient extends AbstractNettyRemoting

@Override
public void init() {
jsbxyyx marked this conversation as resolved.
Show resolved Hide resolved
timerExecutor.scheduleAtFixedRate(() -> clientChannelManager.reconnect(getTransactionServiceGroup()), SCHEDULE_DELAY_MILLS, SCHEDULE_INTERVAL_MILLS, TimeUnit.MILLISECONDS);
timerExecutor.scheduleAtFixedRate(() -> {
try {
clientChannelManager.reconnect(getTransactionServiceGroup());
} catch (Exception ex) {
LOGGER.warn("reconnect TC error. reason: {}", ex.getMessage());
}
}, SCHEDULE_DELAY_MILLS, SCHEDULE_INTERVAL_MILLS, TimeUnit.MILLISECONDS);
if (this.isEnableClientBatchSendRequest()) {
mergeSendExecutorService = new ThreadPoolExecutor(MAX_MERGE_SEND_THREAD,
MAX_MERGE_SEND_THREAD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,21 @@ void reconnect(List<String> availList, String transactionServiceGroup) {
}
if (failedMap.size() > 0) {
if (LOGGER.isInfoEnabled()) {
LOGGER.error("{} can not connect to {} cause:{}", FrameworkErrorCode.NetConnect.getErrCode(), failedMap.keySet(), failedMap.values().stream().map(Throwable::getMessage).collect(Collectors.toSet()));
LOGGER.error("{} can not connect to {} cause:{}", FrameworkErrorCode.NetConnect.getErrCode(),
failedMap.keySet(),
failedMap.values().stream().map(Throwable::getMessage).collect(Collectors.toSet()));
} else if (LOGGER.isDebugEnabled()) {
failedMap.forEach((key, value) -> {
LOGGER.error("{} can not connect to {} cause:{} trace information:{}", FrameworkErrorCode.NetConnect.getErrCode(), key, value.getMessage(), value);
LOGGER.error("{} can not connect to {} cause:{} trace information:{}",
FrameworkErrorCode.NetConnect.getErrCode(), key, value.getMessage(), value);
});
}
boolean failFast = NettyClientConfig.isEnableClientChannelCheckFailFast();
boolean main = Thread.currentThread().getId() == 1L;
funky-eyes marked this conversation as resolved.
Show resolved Hide resolved
if (failFast && main) {
String invalidAddress = StringUtils.join(failedMap.keySet().iterator(), ", ");
throw new FrameworkException("can not connect to [" + invalidAddress + "]");
}
}
} finally {
if (CollectionUtils.isNotEmpty(channelAddress)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.seata.core.constants.ConfigurationKeys;
import io.seata.core.rpc.TransportServerType;

import static io.seata.common.DefaultValues.DEFAULT_CLIENT_CHANNEL_CHECK_FAIL_FAST;
import static io.seata.common.DefaultValues.DEFAULT_ENABLE_CLIENT_BATCH_SEND_REQUEST;
import static io.seata.common.DefaultValues.DEFAULT_RPC_RM_REQUEST_TIMEOUT;
import static io.seata.common.DefaultValues.DEFAULT_RPC_TM_REQUEST_TIMEOUT;
Expand Down Expand Up @@ -59,6 +60,7 @@ public class NettyClientConfig extends NettyBaseConfig {
private static final boolean DEFAULT_POOL_TEST_RETURN = true;
private static final boolean DEFAULT_POOL_LIFO = true;
private static final boolean ENABLE_CLIENT_BATCH_SEND_REQUEST = CONFIG.getBoolean(ConfigurationKeys.ENABLE_CLIENT_BATCH_SEND_REQUEST, DEFAULT_ENABLE_CLIENT_BATCH_SEND_REQUEST);
private static final boolean ENABLE_CLIENT_CHANNEL_CHECK_FAIL_FAST = CONFIG.getBoolean(io.seata.common.ConfigurationKeys.ENABLE_CLIENT_CHANNEL_CHECK_FAIL_FAST, DEFAULT_CLIENT_CHANNEL_CHECK_FAIL_FAST);

/**
* Gets connect timeout millis.
Expand Down Expand Up @@ -455,4 +457,8 @@ public String getRmDispatchThreadPrefix() {
public static boolean isEnableClientBatchSendRequest() {
return ENABLE_CLIENT_BATCH_SEND_REQUEST;
}

public static boolean isEnableClientChannelCheckFailFast() {
return ENABLE_CLIENT_CHANNEL_CHECK_FAIL_FAST;
}
}
Loading