You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2020/06/11 16:03:29 UTC

[skywalking] branch bug-fix created (now 673cfca)

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

wusheng pushed a change to branch bug-fix
in repository https://gitbox.apache.org/repos/asf/skywalking.git.


      at 673cfca  Fix 2 high priority bugs

This branch includes the following new commits:

     new 673cfca  Fix 2 high priority bugs

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[skywalking] 01/01: Fix 2 high priority bugs

Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 673cfcafa8f5bb761ad7402e16a74131d3b3089d
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Fri Jun 12 00:03:09 2020 +0800

    Fix 2 high priority bugs
---
 .../elasticsearch/base/StorageEsInstaller.java     | 37 +++++++++++++---------
 .../plugin/jdbc/h2/dao/H2TopNRecordsQueryDAO.java  |  4 +--
 2 files changed, 24 insertions(+), 17 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 ac69acf..280d378 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
@@ -19,14 +19,12 @@
 package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base;
 
 import com.google.gson.Gson;
-
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
-
 import lombok.extern.slf4j.Slf4j;
-
 import org.apache.skywalking.apm.util.StringUtil;
+import org.apache.skywalking.oap.server.core.analysis.DownSampling;
 import org.apache.skywalking.oap.server.core.storage.StorageException;
 import org.apache.skywalking.oap.server.core.storage.model.Model;
 import org.apache.skywalking.oap.server.core.storage.model.ModelColumn;
@@ -56,7 +54,10 @@ public class StorageEsInstaller extends ModelInstaller {
     protected boolean isExists(Model model) throws StorageException {
         ElasticSearchClient esClient = (ElasticSearchClient) client;
         try {
-            String timeSeriesIndexName = TimeSeriesUtils.latestWriteIndexName(model);
+            String timeSeriesIndexName =
+                DownSampling.None.equals(model.getDownsampling()) ?
+                    model.getName() :
+                    TimeSeriesUtils.latestWriteIndexName(model);
             return esClient.isExistsTemplate(model.getName()) && esClient.isExistsIndex(timeSeriesIndexName);
         } catch (IOException e) {
             throw new StorageException(e.getMessage());
@@ -73,22 +74,28 @@ public class StorageEsInstaller extends ModelInstaller {
             .toString());
 
         try {
-            if (!esClient.isExistsTemplate(model.getName())) {
-                boolean isAcknowledged = esClient.createTemplate(model.getName(), settings, mapping);
-                log.info(
-                    "create {} index template finished, isAcknowledged: {}", model.getName(), isAcknowledged);
-                if (!isAcknowledged) {
-                    throw new StorageException("create " + model.getName() + " index template failure, ");
+            String indexName;
+            if (DownSampling.None.equals(model.getDownsampling())) {
+                indexName = model.getName();
+            } else {
+                if (!esClient.isExistsTemplate(model.getName())) {
+                    boolean isAcknowledged = esClient.createTemplate(model.getName(), settings, mapping);
+                    log.info(
+                        "create {} index template finished, isAcknowledged: {}", model.getName(), isAcknowledged);
+                    if (!isAcknowledged) {
+                        throw new StorageException("create " + model.getName() + " index template failure, ");
+                    }
                 }
+                indexName = TimeSeriesUtils.latestWriteIndexName(model);
             }
-            String timeSeriesIndexName = TimeSeriesUtils.latestWriteIndexName(model);
-            if (!esClient.isExistsIndex(timeSeriesIndexName)) {
-                boolean isAcknowledged = esClient.createIndex(timeSeriesIndexName);
-                log.info("create {} index finished, isAcknowledged: {}", timeSeriesIndexName, isAcknowledged);
+            if (!esClient.isExistsIndex(indexName)) {
+                boolean isAcknowledged = esClient.createIndex(indexName);
+                log.info("create {} index finished, isAcknowledged: {}", indexName, isAcknowledged);
                 if (!isAcknowledged) {
-                    throw new StorageException("create " + timeSeriesIndexName + " time series index failure, ");
+                    throw new StorageException("create " + indexName + " time series index failure, ");
                 }
             }
+
         } catch (IOException e) {
             throw new StorageException(e.getMessage());
         }
diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TopNRecordsQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TopNRecordsQueryDAO.java
index fe34e0e..82a6655 100644
--- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TopNRecordsQueryDAO.java
+++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TopNRecordsQueryDAO.java
@@ -49,12 +49,12 @@ public class H2TopNRecordsQueryDAO implements ITopNRecordsQueryDAO {
         List<Object> parameters = new ArrayList<>(10);
 
         if (StringUtil.isNotEmpty(condition.getParentService())) {
-            sql.append(" service_id = ? ");
+            sql.append(" service_id = ? and");
             final String serviceId = IDManager.ServiceID.buildId(condition.getParentService(), condition.isNormal());
             parameters.add(serviceId);
         }
 
-        sql.append(" and ").append(TopN.TIME_BUCKET).append(" >= ?");
+        sql.append(" ").append(TopN.TIME_BUCKET).append(" >= ?");
         parameters.add(duration.getStartTimeBucketInSec());
         sql.append(" and ").append(TopN.TIME_BUCKET).append(" <= ?");
         parameters.add(duration.getEndTimeBucketInSec());