mirror of
https://github.com/actiontech/dble.git
synced 2026-01-29 00:39:28 -06:00
fix heartbeat timeout inner 1371 (cherry pick) (#3369)
This commit is contained in:
@@ -48,6 +48,8 @@ public abstract class PhysicalDbInstance {
|
||||
private final LongAdder writeCount = new LongAdder();
|
||||
|
||||
private final AtomicBoolean isInitial = new AtomicBoolean(false);
|
||||
private AtomicBoolean initHeartbeat = new AtomicBoolean(false);
|
||||
|
||||
|
||||
// connection pool
|
||||
private ConnectionPool connectionPool;
|
||||
@@ -340,15 +342,19 @@ public abstract class PhysicalDbInstance {
|
||||
}
|
||||
|
||||
heartbeat.start();
|
||||
heartbeat.setScheduledFuture(Scheduler.getInstance().getScheduledExecutor().scheduleAtFixedRate(() -> {
|
||||
if (DbleServer.getInstance().getConfig().isFullyConfigured()) {
|
||||
if (TimeUtil.currentTimeMillis() < heartbeatRecoveryTime) {
|
||||
return;
|
||||
}
|
||||
if (initHeartbeat.compareAndSet(false, true)) {
|
||||
heartbeat.setScheduledFuture(Scheduler.getInstance().getScheduledExecutor().scheduleAtFixedRate(() -> {
|
||||
if (DbleServer.getInstance().getConfig().isFullyConfigured()) {
|
||||
if (TimeUtil.currentTimeMillis() < heartbeatRecoveryTime) {
|
||||
return;
|
||||
}
|
||||
|
||||
heartbeat.heartbeat();
|
||||
}
|
||||
}, 0L, config.getPoolConfig().getHeartbeatPeriodMillis(), MILLISECONDS));
|
||||
heartbeat.heartbeat();
|
||||
}
|
||||
}, 0L, config.getPoolConfig().getHeartbeatPeriodMillis(), MILLISECONDS));
|
||||
} else {
|
||||
LOGGER.warn("init dbInstance[{}] heartbeat, but it has been initialized, skip initialization.", heartbeat.getSource().getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void start(String reason) {
|
||||
@@ -361,6 +367,9 @@ public abstract class PhysicalDbInstance {
|
||||
|
||||
public void stop(String reason, boolean closeFront) {
|
||||
heartbeat.stop(reason);
|
||||
if (!heartbeat.isStop()) {
|
||||
initHeartbeat.set(false);
|
||||
}
|
||||
if (dbGroupConfig.getRwSplitMode() != RW_SPLIT_OFF || dbGroup.getWriteDbInstance() == this) {
|
||||
LOGGER.info("stop connection pool of physical db instance[{}], due to {}", name, reason);
|
||||
connectionPool.stop(reason, closeFront);
|
||||
|
||||
Reference in New Issue
Block a user