reload hang #507

This commit is contained in:
yanhuqing
2018-04-13 14:49:59 +08:00
parent ebcc4f5a69
commit 5864a60808
5 changed files with 28 additions and 18 deletions

View File

@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.actiontech</groupId>
<artifactId>dble</artifactId>
<version>2.18.02.0</version>
<version>2.18.02.1-dev</version>
<packaging>jar</packaging>
<name>dble-server</name>
<description>The project of dble-server</description>

View File

@@ -15,6 +15,7 @@ import com.actiontech.dble.config.loader.xml.XMLSchemaLoader;
import com.actiontech.dble.config.loader.xml.XMLServerLoader;
import com.actiontech.dble.config.model.*;
import com.actiontech.dble.config.util.ConfigException;
import com.actiontech.dble.log.alarm.AlarmCode;
import com.actiontech.dble.route.sequence.handler.DistributedSequenceHandler;
import com.actiontech.dble.route.sequence.handler.IncrSequenceMySQLHandler;
import com.actiontech.dble.route.sequence.handler.IncrSequenceTimeHandler;
@@ -171,9 +172,7 @@ public class ConfigInitializer {
for (SchemaConfig sc : schemas.values()) {
// check dataNode / dataHost
Set<String> dataNodeNames = sc.getAllDataNodes();
for (String dataNodeName : dataNodeNames) {
allUseDataNode.add(dataNodeName);
}
allUseDataNode.addAll(dataNodeNames);
}
// add global sequence node when it is some dedicated servers */
@@ -235,24 +234,33 @@ public class ConfigInitializer {
boolean isConnected = ds.testConnection(database);
map.put(key, isConnected);
} catch (IOException e) {
LOGGER.info("test conn " + key + " error:", e);
LOGGER.warn(AlarmCode.CORE_GENERAL_WARN + "test conn " + key + " error:", e);
}
}
}
}
boolean isConnectivity = true;
List<String> errKeys = new ArrayList<>();
for (Map.Entry<String, Boolean> entry : map.entrySet()) {
String key = entry.getKey();
Boolean value = entry.getValue();
if (!value && isConnectivity) {
LOGGER.info("SelfCheck### test " + key + " database connection failed ");
LOGGER.warn(AlarmCode.CORE_GENERAL_WARN + "SelfCheck### test " + key + " database connection failed ");
errKeys.add(key);
isConnectivity = false;
} else {
LOGGER.info("SelfCheck### test " + key + " database connection success ");
}
}
if (!isConnectivity) {
throw new ConfigException("SelfCheck### there are some datasource connection failed, pls check!");
StringBuilder sb = new StringBuilder("SelfCheck### there are some datasource connection failed, pls check these datasource:");
for (String key : errKeys) {
sb.append("[");
sb.append(key);
sb.append("].");
}
throw new ConfigException(sb.toString());
}
}
}

View File

@@ -7,23 +7,20 @@ package com.actiontech.dble.manager.response;
import com.actiontech.dble.DbleServer;
import com.actiontech.dble.backend.BackendConnection;
import com.actiontech.dble.cluster.ClusterParamCfg;
import com.actiontech.dble.config.loader.ucoreprocess.*;
import com.actiontech.dble.config.loader.ucoreprocess.loader.UConfigStatusResponse;
import com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ConfStatus;
import com.actiontech.dble.net.FrontendConnection;
import com.actiontech.dble.server.ServerConnection;
import com.actiontech.dble.route.RouteResultsetNode;
import com.actiontech.dble.backend.datasource.PhysicalDBNode;
import com.actiontech.dble.backend.datasource.PhysicalDBPool;
import com.actiontech.dble.backend.datasource.PhysicalDatasource;
import com.actiontech.dble.backend.mysql.nio.MySQLConnection;
import com.actiontech.dble.cluster.ClusterParamCfg;
import com.actiontech.dble.config.ConfigInitializer;
import com.actiontech.dble.config.ErrorCode;
import com.actiontech.dble.config.ServerConfig;
import com.actiontech.dble.config.loader.ucoreprocess.*;
import com.actiontech.dble.config.loader.ucoreprocess.loader.UConfigStatusResponse;
import com.actiontech.dble.config.loader.zkprocess.comm.ZkConfig;
import com.actiontech.dble.config.loader.zkprocess.xmltozk.XmltoZkMain;
import com.actiontech.dble.config.loader.zkprocess.zktoxml.listen.ConfigStatusListener;
import com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ConfStatus;
import com.actiontech.dble.config.model.ERTable;
import com.actiontech.dble.config.model.FirewallConfig;
import com.actiontech.dble.config.model.SchemaConfig;
@@ -31,13 +28,16 @@ import com.actiontech.dble.config.model.UserConfig;
import com.actiontech.dble.config.util.DnPropertyUtil;
import com.actiontech.dble.log.AlarmAppender;
import com.actiontech.dble.manager.ManagerConnection;
import com.actiontech.dble.net.FrontendConnection;
import com.actiontech.dble.net.NIOProcessor;
import com.actiontech.dble.net.mysql.OkPacket;
import com.actiontech.dble.route.RouteResultsetNode;
import com.actiontech.dble.route.parser.ManagerParseConfig;
import com.actiontech.dble.server.ServerConnection;
import com.actiontech.dble.server.variables.SystemVariables;
import com.actiontech.dble.server.variables.VarsExtractorHandler;
import com.actiontech.dble.util.KVPathUtil;
import com.actiontech.dble.util.ZKUtils;
import com.actiontech.dble.route.parser.ManagerParseConfig;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.locks.InterProcessMutex;
import org.apache.curator.utils.ZKPaths;
@@ -307,7 +307,7 @@ public final class ReloadConfig {
/* 2.1 do nothing */
boolean isReloadStatusOK = true;
String reasonMsg = null;
/* 2.2 init the new dataSource */
for (PhysicalDBPool dbPool : newDataHosts.values()) {
String hostName = dbPool.getHostName();
@@ -329,6 +329,7 @@ public final class ReloadConfig {
dbPool.init(Integer.parseInt(dnIndex));
if (!dbPool.isInitSuccess()) {
isReloadStatusOK = false;
reasonMsg = "Init DbPool [" + dbPool.getHostName() + "] failed";
break;
}
}
@@ -347,7 +348,7 @@ public final class ReloadConfig {
dbPool.clearDataSources("reload config");
dbPool.stopHeartbeat();
}
throw new Exception("Init DbPool failed");
throw new Exception(reasonMsg);
}
}

View File

@@ -26,6 +26,7 @@ public class MysqlVarsListener implements SQLQueryResultListener<SQLQueryResult<
if (!result.isSuccess()) {
//not thread safe
LOGGER.warn(AlarmCode.CORE_GENERAL_WARN + "Can't get variables from DataNode: " + result.getDataNode() + "!");
handler.signalDone();
return;
}

View File

@@ -56,7 +56,7 @@ public class VarsExtractorHandler {
}
private void signalDone() {
public void signalDone() {
lock.lock();
try {
extracting = true;