未验证 提交 b8fadec0 编写于 作者: Z zhyyu 提交者: GitHub

fix slow db dynamic config bug (#7192)

上级 a966eea3
......@@ -46,6 +46,7 @@ Release Notes.
* Fix CounterWindow increase computing issue.
* Performance: optimize Envoy ALS analyzer performance in high traffic load scenario (reduce ~1cpu in ~10k RPS).
* Performance: trim useless metadata fields in Envoy ALS metadata to improve performance.
* Fix: slowDBAccessThreshold dynamic config error when not configured.
#### UI
* Fix the date component for log conditions.
......
......@@ -23,17 +23,17 @@ import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.skywalking.oap.server.analyzer.module.AnalyzerModule;
import org.apache.skywalking.oap.server.configuration.api.ConfigChangeWatcher;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.library.module.ModuleProvider;
public class DBLatencyThresholdsAndWatcher extends ConfigChangeWatcher {
private AtomicReference<Map<String, Integer>> thresholds;
private AtomicReference<String> settingsString;
private final String initialSettingsString;
private volatile String dynamicSettingsString;
public DBLatencyThresholdsAndWatcher(String config, ModuleProvider provider) {
super(AnalyzerModule.NAME, provider, "slowDBAccessThreshold");
thresholds = new AtomicReference<>(new HashMap<>());
settingsString = new AtomicReference<>(Const.EMPTY_STRING);
initialSettingsString = config;
activeSetting(config);
}
......@@ -47,12 +47,8 @@ public class DBLatencyThresholdsAndWatcher extends ConfigChangeWatcher {
newThresholds.put(typeValue[0].trim().toLowerCase(), Integer.parseInt(typeValue[1].trim()));
}
}
if (!newThresholds.containsKey("default")) {
newThresholds.put("default", 10000);
}
thresholds.set(newThresholds);
settingsString.set(config);
}
public int getThreshold(String type) {
......@@ -67,14 +63,16 @@ public class DBLatencyThresholdsAndWatcher extends ConfigChangeWatcher {
@Override
public void notify(ConfigChangeEvent value) {
if (EventType.DELETE.equals(value.getEventType())) {
activeSetting("");
dynamicSettingsString = null;
activeSetting(initialSettingsString);
} else {
dynamicSettingsString = value.getNewValue();
activeSetting(value.getNewValue());
}
}
@Override
public String value() {
return settingsString.get();
return dynamicSettingsString;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册