yyshiningyear opened a new issue, #3559:
URL: https://github.com/apache/servicecomb-java-chassis/issues/3559
问题现象:
按照对隔离配置的理解,当连续错误数配置为0时会使用错误率作为判断规则,然而在现网没有配置连续错误数,只配置了错误率的请求下,发现现网的隔离日志中还是按照连续错误数为5来判断隔离的,导致现网经常出现隔离;
代码分析:
在判断是否满足隔离条件时,`continuousFailureThreshold` 的优先级要大于`errorThresholdPercentage`
,当`continuousFailureThreshold <=0`时才会判断错误率:
```java
private boolean checkThresholdAllowed(Settings settings,
ServiceCombServerStats serverStats) {
if (serverStats.getTotalRequests() < settings.enableRequestThreshold) {
return true;
}
if (settings.continuousFailureThreshold > 0) {
// continuousFailureThreshold has higher priority to decide the result
if (serverStats.getContinuousFailureCount() >=
settings.continuousFailureThreshold) {
return false;
}
}
if (settings.errorThresholdPercentage == 0) {
return true;
}
return serverStats.getFailedRate() < settings.errorThresholdPercentage;
}
```
然而在初始化 `continuousFailureThreshold`
时,判断了只有配置项大于0时才会取配置项的值,否则取的是默认值5;这就导致`continuousFailureThreshold`
一直大于0,也就一直会优先错误率判断
```java
//
https://github.com/apache/servicecomb-java-chassis/tree/master/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/Configuration.java
public int getContinuousFailureThreshold(String microservice) {
return getThreshold(microservice, FILTER_CONTINUOUS_FAILURE_THRESHOLD);
}
private int getThreshold(String microservice, String threshold) {
final int defaultValue = 5;
String p = getStringProperty("5",
ROOT + microservice + "." + FILTER_ISOLATION + threshold,
ROOT + FILTER_ISOLATION + threshold);
try {
int result = Integer.parseInt(p);
if (result > 0) { // 这里的判断导致无法配置非正数
return result;
}
return defaultValue;
} catch (NumberFormatException e) {
return defaultValue;
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]