Skip to content

Commit f30e6e1

Browse files
committed
show variables exception
1 parent 52f40b8 commit f30e6e1

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/main/java/com/actiontech/dble/DbleServer.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,12 @@ private void pullVarAndMeta() throws IOException {
271271
if (!this.getConfig().isDataHostWithoutWR()) {
272272
//init for sys VAR
273273
VarsExtractorHandler handler = new VarsExtractorHandler(config.getDataHosts());
274-
systemVariables = handler.execute();
274+
SystemVariables newSystemVariables = handler.execute();
275+
if (newSystemVariables == null) {
276+
throw new IOException("Can't get variables from data node");
277+
} else {
278+
systemVariables = newSystemVariables;
279+
}
275280
reviseSchemas();
276281
initDataHost();
277282
//init tmManager

src/main/java/com/actiontech/dble/manager/response/ReloadConfig.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.slf4j.Logger;
4444
import org.slf4j.LoggerFactory;
4545

46+
import java.io.IOException;
4647
import java.nio.charset.StandardCharsets;
4748
import java.util.ArrayList;
4849
import java.util.List;
@@ -274,10 +275,13 @@ public static void reloadAll(final int loadAllMode) throws Exception {
274275
Map<ERTable, Set<ERTable>> newErRelations = loader.getErRelations();
275276
FirewallConfig newFirewall = loader.getFirewall();
276277

277-
SystemVariables newSystemVariables = DbleServer.getInstance().getSystemVariables();
278+
SystemVariables newSystemVariables = null;
278279
if (!loader.isDataHostWithoutWH()) {
279280
VarsExtractorHandler handler = new VarsExtractorHandler(newDataHosts);
280281
newSystemVariables = handler.execute();
282+
if (newSystemVariables == null) {
283+
throw new IOException("Can't get variables from data node");
284+
}
281285
ConfigInitializer confInit = new ConfigInitializer(newSystemVariables.isLowerCaseTableNames());
282286
newUsers = confInit.getUsers();
283287
newSchemas = confInit.getSchemas();

src/main/java/com/actiontech/dble/server/variables/VarsExtractorHandler.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class VarsExtractorHandler {
2727
private Lock lock;
2828
private Condition done;
2929
private Map<String, PhysicalDBPool> dataHosts;
30-
private SystemVariables systemVariables = new SystemVariables();
30+
private volatile SystemVariables systemVariables = null;
3131
public VarsExtractorHandler(Map<String, PhysicalDBPool> dataHosts) {
3232
this.dataHosts = dataHosts;
3333
this.extracting = false;
@@ -77,7 +77,8 @@ private PhysicalDatasource getPhysicalDatasource() {
7777
return ds;
7878
}
7979

80-
public void handleVars(Map<String, String> vars) {
80+
void handleVars(Map<String, String> vars) {
81+
systemVariables = new SystemVariables();
8182
for (Map.Entry<String, String> entry : vars.entrySet()) {
8283
String key = entry.getKey();
8384
String value = entry.getValue();

0 commit comments

Comments
 (0)