lokidundun commented on code in PR #7783:
URL: https://github.com/apache/incubator-seata/pull/7783#discussion_r2527580642
##########
core/src/main/java/org/apache/seata/core/rpc/netty/AbstractNettyRemotingClient.java:
##########
@@ -271,6 +287,11 @@ public void destroyChannel(String serverAddress, Channel
channel) {
@Override
public void destroy() {
+ if (reconnectTimer != null && timerStarted.get()) {
+ reconnectTimer.shutdown();
Review Comment:
> When reconnectTimer runs shutdown(), it does not interrupt ongoing tasks,
which means that reconnection may still occur after destruction.
It means that I should use the `reconnectTimer.shutdownNow()` not the
`reconnectTimer.shutdown()` to stop all active tasks,right?
> Aside from the reconnection issue, logically speaking, there is also a
race condition problem here.
It means that I ought to use ` protected final ReentrantLock mergeLock = new
ReentrantLock()` to promise the Atomicity,like this?
```
public void destroy() {
mergeLock.lock();
try {
if (reconnectTimer != null && timerStarted.get()) {
reconnectTimer.shutdown();
timerStarted.set(false);
LOGGER.info("Instance reconnect timer stopped (role: {})",
transactionRole.name());
}
clientBootstrap.shutdown();
if (mergeSendExecutorService != null) {
mergeSendExecutorService.shutdown();
}
super.destroy();
} finally {
mergeLock.unlock();
}
}
```
##########
core/src/main/java/org/apache/seata/core/rpc/netty/AbstractNettyRemotingClient.java:
##########
@@ -96,6 +99,10 @@ public abstract class AbstractNettyRemotingClient extends
AbstractNettyRemoting
protected final Condition mergeCondition = mergeLock.newCondition();
protected volatile boolean isSending = false;
+ private final Runnable reconnectTask;
+ private ScheduledExecutorService reconnectTimer;
Review Comment:
> It's probably better to have a globally unique one here, otherwise there
would be multiple reconnectTimers.
I haven't come up with a perfect solution for now. Could you please share
your thoughts?❤️
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]