Skip to content

Commit

Permalink
2.19.09.0 1467 related bug fix (#1502)
Browse files Browse the repository at this point in the history
* #1467 add sysparam show and corrective notice error

* #1467 rebuild the dataHost in reload even if the standby dataSource changes

* #1467 code sytle change

* #1499 add new param for myid conf
  • Loading branch information
sunsun314 authored and yanhuqing666 committed Nov 15, 2019
1 parent 17b3c61 commit 9a66a4e
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,30 @@ private Set<PhysicalDatasourceDiff> createHostChangeSet(AbstractPhysicalDBPool n
for (int i = 0; i < newDbPool.getWriteSources().length; i++) {
PhysicalDatasource writeHost = newDbPool.getWriteSources()[i];
PhysicalDatasource[] readHost = newDbPool.getReadSources().get(i);
PhysicalDatasource[] standByHost = newDbPool.getStandbyReadSourcesMap().get(i);

PhysicalDatasource orgHost = null;
PhysicalDatasource[] relatedHost = null;
for (int j = 0; j < orgDbPool.getWriteSources().length; j++) {
PhysicalDatasource oldHost = orgDbPool.getWriteSources()[j];
PhysicalDatasource[] oldRHost = orgDbPool.getReadSources().get(j);
PhysicalDatasource[] oldStandByHost = orgDbPool.getStandbyReadSourcesMap().get(j);


if (oldHost.equals(writeHost) &&
((oldRHost == null && readHost == null) ||
((oldRHost != null && readHost != null) && oldRHost.length == readHost.length))) {
((oldRHost == null && readHost == null) || ((oldRHost != null && readHost != null) && oldRHost.length == readHost.length)) &&
((oldStandByHost == null && standByHost == null) || ((oldStandByHost != null && standByHost != null) && oldStandByHost.length == standByHost.length))) {
boolean sameFlag = true;
if (oldRHost != null) {
for (int k = 0; k < oldRHost.length; k++) {
if (!oldRHost[k].equals(readHost[k])) {
sameFlag = false;
break;
} else {
oldRHost[k].setTestConnSuccess(readHost[k].isTestConnSuccess());
}
}

//compare the readHost is the same
sameFlag = calculateForDataSources(oldRHost, readHost);
//compare the sandByHost is the same
if (sameFlag) {
sameFlag = calculateForDataSources(oldStandByHost, standByHost);
}

//only when the writeHost is the same && readHost list is the same && standByHost is the same
// that means the two dataHost is the same
if (sameFlag) {
//update connection test result
oldHost.setTestConnSuccess(writeHost.isTestConnSuccess());
Expand All @@ -86,6 +89,7 @@ private Set<PhysicalDatasourceDiff> createHostChangeSet(AbstractPhysicalDBPool n
break;
}
}

}

if (orgHost != null) {
Expand Down Expand Up @@ -115,6 +119,20 @@ private Set<PhysicalDatasourceDiff> createHostChangeSet(AbstractPhysicalDBPool n
return hostDiff;
}


private boolean calculateForDataSources(PhysicalDatasource[] olds, PhysicalDatasource[] news) {
if (olds != null) {
for (int k = 0; k < olds.length; k++) {
if (!olds[k].equals(news[k])) {
return false;
} else {
olds[k].setTestConnSuccess(news[k].isTestConnSuccess());
}
}
}
return true;
}

// private Set<BaseInfoDiff> createBaseDiff(PhysicalDBPool newDbPool, PhysicalDBPool orgDbPool) {
// Set<BaseInfoDiff> baseDiffSet = new HashSet<BaseInfoDiff>();
// if (newDbPool.getDataHostConfig().getBalance() != orgDbPool.getDataHostConfig().getBalance()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static void execute(Matcher disable, ManagerConnection mc) {
packet.setServerStatus(2);
packet.write(mc);
} else {
mc.writeErrMessage(ErrorCode.ER_YES, "dataHost mod not allowed to disable");
mc.writeErrMessage(ErrorCode.ER_YES, "dble server not in useOuterHa mode");
}
} finally {
lock.readLock().unlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static void execute(Matcher enable, ManagerConnection mc) {
packet.setServerStatus(2);
packet.write(mc);
} else {
mc.writeErrMessage(ErrorCode.ER_YES, "dataHost " + dhName + " do not exists");
mc.writeErrMessage(ErrorCode.ER_YES, "dble server not in useOuterHa mode");
}
} finally {
lock.readLock().unlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static void execute(Matcher switcher, ManagerConnection mc) {
packet.setServerStatus(2);
packet.write(mc);
} else {
mc.writeErrMessage(ErrorCode.ER_YES, "dataHost " + dhName + " do not exists");
mc.writeErrMessage(ErrorCode.ER_YES, "dble server not in useOuterHa mode");
}
} finally {
lock.readLock().unlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public static void execute(ManagerConnection c) {
paramValues.add(sysConfig.getSqlSlowTime() + "ms");
paramValues.add(sysConfig.getMaxCharsPerColumn() + "");
paramValues.add(sysConfig.getMaxRowSizeToFile() + "");
paramValues.add(sysConfig.isUseOuterHa() + "");


for (int i = 0; i < PARAM_NAMES.length; i++) {
Expand Down Expand Up @@ -252,6 +253,7 @@ public static void execute(ManagerConnection c) {
"sqlSlowTime",
"maxCharsPerColumn",
"maxRowSizeToFile",
"useOuterHa",
};

private static final String[] PARAM_DESCRIPTION = {
Expand Down Expand Up @@ -335,6 +337,7 @@ public static void execute(ManagerConnection c) {
"The threshold of Slow Query, the default is 100ms",
"The maximum number of characters allowed for per column when load data.The default value is 65535",
"The maximum row size,if over this value,row data will be saved to file when load data.The default value is 10000",
"Whether use outer ha component ",
};

private static final String[] ISOLATION_LEVELS = {"", "READ_UNCOMMITTED", "READ_COMMITTED", "REPEATABLE_READ", "SERIALIZABLE"};
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/myid.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ clusterId=cluster-1
#it must be different for every node in cluster
myid=server_02
serverID=server_02
clusterHa=false

0 comments on commit 9a66a4e

Please sign in to comment.