fix: newly added instance needs to create a connection pool immediately (#3334)

This commit is contained in:
LUA
2022-08-04 13:52:42 +08:00
committed by GitHub
parent ac939790ed
commit 2040d05794
2 changed files with 9 additions and 3 deletions
@@ -467,9 +467,11 @@ public abstract class PhysicalDbInstance implements ReadTimeStatusInstance {
public void updatePoolCapacity() {
//minCon/maxCon/numOfShardingNodes
checkPoolSize();
connectionPool.evictImmediately();
connectionPool.fillPool();
if ((dbGroupConfig.getRwSplitMode() != RW_SPLIT_OFF || dbGroup.getWriteDbInstance() == this) && !dbGroup.isUseless()) {
checkPoolSize();
connectionPool.evictImmediately();
connectionPool.fillPool();
}
}
public void closeAllConnection(String reason) {
@@ -227,6 +227,10 @@ public class MySQLHeartbeat {
Map<String, String> labels = AlertUtil.genSingleLabel("dbInstance", this.source.getDbGroupConfig().getName() + "-" + this.source.getConfig().getInstanceName());
AlertUtil.alertResolve(AlarmCode.HEARTBEAT_FAIL, Alert.AlertLevel.WARN, "mysql", this.source.getConfig().getId(), labels);
}
//after the heartbeat changes from failure to success, it needs to be expanded immediately
if (source.getTotalConnections() == 0) {
source.updatePoolCapacity();
}
if (isStop) {
LOGGER.warn("heartbeat[{}] had been stop", source.getConfig().getUrl());
detector.quit();