Skip to content

Commit e0ba856

Browse files
committed
fix: rows that do not need to be changed are not correctly removed during update or delete
1 parent 617b46a commit e0ba856

File tree

3 files changed

+38
-25
lines changed

3 files changed

+38
-25
lines changed

src/main/java/com/actiontech/dble/services/manager/information/ManagerTableUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ public static Set<LinkedHashMap<String, String>> getAffectPks(ManagerService man
112112
String value = null == row.getValue(i) ? null : new String(row.getValue(i), charset);
113113
affectPk.put(columnName, value);
114114
if (null != values) {
115-
boolean match = values.entrySet().stream().anyMatch(valueEntry -> !StringUtil.equals(affectPk.get(valueEntry.getKey()), valueEntry.getValue()));
116-
if (!match) {
115+
boolean isSkipRow = values.entrySet().stream().allMatch(valueEntry -> affectPk.containsKey(valueEntry.getKey()) && StringUtil.equals(affectPk.get(valueEntry.getKey()), valueEntry.getValue()));
116+
if (isSkipRow) {
117117
breakFlag = true;
118118
break;
119119
}

src/main/java/com/actiontech/dble/services/manager/information/tables/DbleDbGroup.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -289,30 +289,30 @@ private void checkRule(LinkedHashMap<String, String> row) {
289289
}
290290
}
291291
}
292-
String delayThresholdStr = row.get(COLUMN_DELAY_THRESHOLD);
293-
String heartbeatTimeoutStr = row.get(COLUMN_HEARTBEAT_TIMEOUT);
294-
String heartbeatRetryStr = row.get(COLUMN_HEARTBEAT_RETRY);
295-
if (!StringUtil.isBlank(delayThresholdStr) && IntegerUtil.parseInt(delayThresholdStr) < -1) {
296-
throw new ConfigException("Column '" + COLUMN_DELAY_THRESHOLD + "' should be an integer greater than or equal to -1!");
297-
}
298-
if (!StringUtil.isBlank(heartbeatTimeoutStr) && IntegerUtil.parseInt(heartbeatTimeoutStr) < 0) {
299-
throw new ConfigException("Column '" + COLUMN_HEARTBEAT_TIMEOUT + "' should be an integer greater than or equal to 0!");
300-
}
301-
if (!StringUtil.isBlank(heartbeatRetryStr) && IntegerUtil.parseInt(heartbeatRetryStr) < 0) {
302-
throw new ConfigException("Column '" + COLUMN_HEARTBEAT_RETRY + "' should be an integer greater than or equal to 0!");
303-
}
304-
String heartbeatKeepAliveStr = row.get(COLUMN_KEEP_ALIVE);
305-
if (!StringUtil.isBlank(heartbeatKeepAliveStr) && IntegerUtil.parseInt(heartbeatKeepAliveStr) < 0) {
306-
throw new ConfigException("Column '" + COLUMN_KEEP_ALIVE + "' should be an integer greater than or equal to 0!");
307-
}
308-
String delayPeriodMillis = row.get(DELAY_PERIOD_MILLIS);
309-
delayDetectionCheck(delayPeriodMillis);
292+
checkInterValue(row);
310293
}
311294
}
312295

313-
private void delayDetectionCheck(String delayPeriodMillis) {
314-
if (!StringUtil.isBlank(delayPeriodMillis) && IntegerUtil.parseInt(delayPeriodMillis) < -1) {
315-
throw new ConfigException("Column '" + COLUMN_DELAY_THRESHOLD + "' should be an integer greater than -1!");
296+
private void checkInterValue(LinkedHashMap<String, String> row) {
297+
String delayThresholdStr = row.get(COLUMN_DELAY_THRESHOLD);
298+
String heartbeatTimeoutStr = row.get(COLUMN_HEARTBEAT_TIMEOUT);
299+
String heartbeatRetryStr = row.get(COLUMN_HEARTBEAT_RETRY);
300+
if (row.containsKey(COLUMN_DELAY_THRESHOLD) && (StringUtil.isBlank(delayThresholdStr) || IntegerUtil.parseInt(delayThresholdStr) < -1)) {
301+
throw new ConfigException("Column '" + COLUMN_DELAY_THRESHOLD + "' should be an integer greater than or equal to -1!");
302+
}
303+
if (row.containsKey(COLUMN_HEARTBEAT_TIMEOUT) && (StringUtil.isBlank(heartbeatTimeoutStr) || IntegerUtil.parseInt(heartbeatTimeoutStr) < 0)) {
304+
throw new ConfigException("Column '" + COLUMN_HEARTBEAT_TIMEOUT + "' should be an integer greater than or equal to 0!");
305+
}
306+
if (row.containsKey(COLUMN_HEARTBEAT_RETRY) && (StringUtil.isBlank(heartbeatRetryStr) || IntegerUtil.parseInt(heartbeatRetryStr) < 0)) {
307+
throw new ConfigException("Column '" + COLUMN_HEARTBEAT_RETRY + "' should be an integer greater than or equal to 0!");
308+
}
309+
String heartbeatKeepAliveStr = row.get(COLUMN_KEEP_ALIVE);
310+
if (row.containsKey(COLUMN_KEEP_ALIVE) && (StringUtil.isBlank(heartbeatKeepAliveStr) || IntegerUtil.parseInt(heartbeatKeepAliveStr) < 0)) {
311+
throw new ConfigException("Column '" + COLUMN_KEEP_ALIVE + "' should be an integer greater than or equal to 0!");
312+
}
313+
String delayPeriodMillis = row.get(DELAY_PERIOD_MILLIS);
314+
if (row.containsKey(DELAY_PERIOD_MILLIS) && (StringUtil.isBlank(delayPeriodMillis) || IntegerUtil.parseInt(delayPeriodMillis) < -1)) {
315+
throw new ConfigException("Column '" + DELAY_PERIOD_MILLIS + "' should be an integer greater than or equal to -1!");
316316
}
317317
}
318318

src/main/java/com/actiontech/dble/services/manager/information/tables/DbleDbInstance.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,8 @@ private DBInstance transformRowToDBInstance(LinkedHashMap<String, String> map) {
402402
DBInstance dbInstance = new DBInstance();
403403
StringBuilder url = new StringBuilder();
404404
List<Property> propertyList = Lists.newArrayList();
405+
String key;
406+
String entryValue;
405407
for (Map.Entry<String, String> entry : map.entrySet()) {
406408
switch (entry.getKey()) {
407409
case COLUMN_NAME:
@@ -469,6 +471,13 @@ private DBInstance transformRowToDBInstance(LinkedHashMap<String, String> map) {
469471
case COLUMN_TEST_ON_BORROW:
470472
case COLUMN_TEST_ON_RETURN:
471473
case COLUMN_TEST_WHILE_IDLE:
474+
key = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, entry.getKey());
475+
entryValue = entry.getValue();
476+
if (StringUtil.isBlank(entryValue) || (!StringUtil.equalsIgnoreCase(entryValue, Boolean.FALSE.toString()) && !StringUtil.equalsIgnoreCase(entryValue, Boolean.TRUE.toString()))) {
477+
throw new ConfigException("Column '" + entry.getKey() + "' values only support 'false' or 'true'.");
478+
}
479+
propertyList.add(new Property(entryValue, key));
480+
break;
472481
case COLUMN_CONNECTION_TIMEOUT:
473482
case COLUMN_CONNECTION_HEARTBEAT_TIMEOUT:
474483
case COLUMN_TIME_BETWEEN_EVICTION_RUNS_MILLIS:
@@ -477,8 +486,12 @@ private DBInstance transformRowToDBInstance(LinkedHashMap<String, String> map) {
477486
case COLUMN_EVICTOR_SHUTDOWN_TIMEOUT_MILLIS:
478487
case COLUMN_FLOW_HIGH_LEVEL:
479488
case COLUMN_FLOW_LOW_LEVEL:
480-
String key = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, entry.getKey());
481-
propertyList.add(new Property(entry.getValue(), key));
489+
key = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, entry.getKey());
490+
entryValue = entry.getValue();
491+
if (StringUtil.isBlank(entryValue) || IntegerUtil.parseInt(entryValue) <= 0) {
492+
throw new ConfigException("Column '" + entry.getKey() + "' should be an integer greater than 0!");
493+
}
494+
propertyList.add(new Property(entryValue, key));
482495
break;
483496
default:
484497
break;

0 commit comments

Comments
 (0)