This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch condition-precise
in repository https://gitbox.apache.org/repos/asf/skywalking.git

commit 0b7b89b9c5c463472460be0d971f1cbb4b0c4023
Author: Wu Sheng <[email protected]>
AuthorDate: Thu Sep 23 09:09:04 2021 +0800

    Only report `bug warning` in precise conditions.
---
 .../storage/plugin/elasticsearch/base/StorageEsInstaller.java | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git 
a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/StorageEsInstaller.java
 
b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/StorageEsInstaller.java
index b678a98..1b464fc 100644
--- 
a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/StorageEsInstaller.java
+++ 
b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/StorageEsInstaller.java
@@ -70,14 +70,17 @@ public class StorageEsInstaller extends ModelInstaller {
         if (!model.isTimeSeries()) {
             return esClient.isExistsIndex(tableName);
         }
-        boolean exist = esClient.isExistsTemplate(tableName)
-            && 
esClient.isExistsIndex(TimeSeriesUtils.latestWriteIndexName(model));
+        boolean templateExists = esClient.isExistsTemplate(tableName);
         final Optional<IndexTemplate> template = 
esClient.getTemplate(tableName);
+        boolean lastIndexExists = 
esClient.isExistsIndex(TimeSeriesUtils.latestWriteIndexName(model));
 
-        if ((exist && !template.isPresent()) || (!exist && 
template.isPresent())) {
-            throw new Error("[Bug warning]ElasticSearch client query template 
result is not consistent. Please file an issue to Apache 
SkyWalking.(https://github.com/apache/skywalking/issues)");
+        if ((templateExists && !template.isPresent()) || (!templateExists && 
template.isPresent())) {
+            throw new Error("[Bug warning] ElasticSearch client query template 
result is not consistent. " +
+                                "Please file an issue to Apache 
SkyWalking.(https://github.com/apache/skywalking/issues)");
         }
 
+        boolean exist = templateExists && lastIndexExists;
+
         if (exist && IndexController.INSTANCE.isMetricModel(model)) {
             structures.putStructure(
                 tableName, template.get().getMappings()

Reply via email to