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

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


The following commit(s) were added to refs/heads/master by this push:
     new 1934f308a7 Fix scroll query in Elastic Search storage (#9128)
1934f308a7 is described below

commit 1934f308a7b295d02741a37c1aa4c799612cf886
Author: mrproliu <[email protected]>
AuthorDate: Wed May 25 19:19:27 2022 +0800

    Fix scroll query in Elastic Search storage (#9128)
---
 docs/en/changes/changes.md                                   |  2 ++
 docs/en/setup/backend/backend-storage.md                     |  1 +
 docs/en/setup/backend/configuration-vocabulary.md            |  1 +
 .../core/profiling/ebpf/analyze/EBPFProfilingAnalyzer.java   |  2 +-
 oap-server/server-starter/src/main/resources/application.yml |  1 +
 .../elasticsearch/StorageModuleElasticsearchConfig.java      |  6 ++++++
 .../plugin/elasticsearch/cache/NetworkAddressAliasEsDAO.java | 10 +++++-----
 .../plugin/elasticsearch/query/EBPFProfilingDataEsDAO.java   | 12 ++++++------
 .../plugin/elasticsearch/query/MetadataQueryEsDAO.java       | 10 +++++-----
 9 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md
index e6d51e520f..39b7e71d54 100644
--- a/docs/en/changes/changes.md
+++ b/docs/en/changes/changes.md
@@ -70,6 +70,8 @@
 * Add TiDB, OpenSearch, Postgres storage optional to Trace and eBPF Profiling 
E2E testing.
 * Add OFF CPU eBPF Profiling E2E Testing.
 * Fix searchableTag as `rpc.status_code` and `http.status_code`. `status_code` 
had been removed.
+* Fix scroll query failure exception.
+* Add `profileDataQueryBatchSize` config in Elasticsearch Storage.
 
 #### UI
 
diff --git a/docs/en/setup/backend/backend-storage.md 
b/docs/en/setup/backend/backend-storage.md
index 28c0ffcb01..708124895c 100644
--- a/docs/en/setup/backend/backend-storage.md
+++ b/docs/en/setup/backend/backend-storage.md
@@ -79,6 +79,7 @@ storage:
     metadataQueryMaxSize: ${SW_STORAGE_ES_QUERY_MAX_SIZE:5000}
     segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200}
     profileTaskQueryMaxSize: ${SW_STORAGE_ES_QUERY_PROFILE_TASK_SIZE:200}
+    profileDataQueryScrollBatchSize: 
${SW_STORAGE_ES_QUERY_PROFILE_DATA_SCROLLING_BATCH_SIZE:100}
     oapAnalyzer: 
${SW_STORAGE_ES_OAP_ANALYZER:"{\"analyzer\":{\"oap_analyzer\":{\"type\":\"stop\"}}}"}
 # the oap analyzer.
     oapLogAnalyzer: 
${SW_STORAGE_ES_OAP_LOG_ANALYZER:"{\"analyzer\":{\"oap_log_analyzer\":{\"type\":\"standard\"}}}"}
 # the oap log analyzer. It could be customized by the ES analyzer 
configuration to support more language log formats, such as Chinese log, 
Japanese log and etc.
     advanced: ${SW_STORAGE_ES_ADVANCED:""}
diff --git a/docs/en/setup/backend/configuration-vocabulary.md 
b/docs/en/setup/backend/configuration-vocabulary.md
index de9c97ba30..e7b37e1c85 100644
--- a/docs/en/setup/backend/configuration-vocabulary.md
+++ b/docs/en/setup/backend/configuration-vocabulary.md
@@ -110,6 +110,7 @@ The Configuration Vocabulary lists all available 
configurations provided by `app
 | -                       | -             | scrollingBatchSize                 
                                                                                
                                                      | The batch size of 
metadata per iteration when `metadataQueryMaxSize` or `resultWindowMaxSize` is 
too large to be retrieved in a single query.                                    
                                                                                
                     [...]
 | -                       | -             | segmentQueryMaxSize                
                                                                                
                                                      | The maximum size of 
trace segments per query.                                                       
                                                                                
                                                                                
                  [...]
 | -                       | -             | profileTaskQueryMaxSize            
                                                                                
                                                      | The maximum size of 
profile task per query.                                                         
                                                                                
                                                                                
                  [...]
+| -                       | -             | profileDataQueryScrollBatchSize    
                                                                                
                                                      | The batch size of query 
profiling data.                                                                 
                                                                                
                                                                                
              [...]
 | -                       | -             | advanced                           
                                                                                
                                                      | All settings of 
ElasticSearch index creation. The value should be in JSON format.               
                                                                                
                                                                                
                      [...]
 | -                       | h2            | -                                  
                                                                                
                                                      | H2 storage is designed 
for demonstration and running in short term (i.e. 1-2 hours) only.              
                                                                                
                                                                                
               [...]
 | -                       | -             | driver                             
                                                                                
                                                      | H2 JDBC driver.         
                                                                                
                                                                                
                                                                                
              [...]
diff --git 
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/analyze/EBPFProfilingAnalyzer.java
 
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/analyze/EBPFProfilingAnalyzer.java
index 88f1648fee..379330cd40 100644
--- 
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/analyze/EBPFProfilingAnalyzer.java
+++ 
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/analyze/EBPFProfilingAnalyzer.java
@@ -50,7 +50,7 @@ import java.util.stream.Stream;
 public class EBPFProfilingAnalyzer {
 
     private static final EBPFProfilingAnalyzeCollector ANALYZE_COLLECTOR = new 
EBPFProfilingAnalyzeCollector();
-    private static final Long FETCH_DATA_DURATION = 
TimeUnit.MINUTES.toMillis(2);
+    private static final Long FETCH_DATA_DURATION = 
TimeUnit.SECONDS.toMillis(10);
 
     private final ModuleManager moduleManager;
     protected IEBPFProfilingDataDAO dataDAO;
diff --git a/oap-server/server-starter/src/main/resources/application.yml 
b/oap-server/server-starter/src/main/resources/application.yml
index 879c27b966..3144d8253d 100755
--- a/oap-server/server-starter/src/main/resources/application.yml
+++ b/oap-server/server-starter/src/main/resources/application.yml
@@ -158,6 +158,7 @@ storage:
     scrollingBatchSize: ${SW_STORAGE_ES_SCROLLING_BATCH_SIZE:5000}
     segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200}
     profileTaskQueryMaxSize: ${SW_STORAGE_ES_QUERY_PROFILE_TASK_SIZE:200}
+    profileDataQueryBatchSize: 
${SW_STORAGE_ES_QUERY_PROFILE_DATA_BATCH_SIZE:100}
     oapAnalyzer: 
${SW_STORAGE_ES_OAP_ANALYZER:"{\"analyzer\":{\"oap_analyzer\":{\"type\":\"stop\"}}}"}
 # the oap analyzer.
     oapLogAnalyzer: 
${SW_STORAGE_ES_OAP_LOG_ANALYZER:"{\"analyzer\":{\"oap_log_analyzer\":{\"type\":\"standard\"}}}"}
 # the oap log analyzer. It could be customized by the ES analyzer 
configuration to support more language log formats, such as Chinese log, 
Japanese log and etc.
     advanced: ${SW_STORAGE_ES_ADVANCED:""}
diff --git 
a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchConfig.java
 
b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchConfig.java
index 06f05d4ba6..50fccf6aab 100644
--- 
a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchConfig.java
+++ 
b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchConfig.java
@@ -117,6 +117,12 @@ public class StorageModuleElasticsearchConfig extends 
ModuleConfig {
     private int scrollingBatchSize = 5000;
     private int segmentQueryMaxSize = 200;
     private int profileTaskQueryMaxSize = 200;
+    /**
+     * The batch size that is used to scroll on the large eBPF profiling data 
result.
+     * The profiling data contains full-stack symbol data, which could make 
ElasticSearch response large content.
+     * {@link #scrollingBatchSize} would not be used in profiling data query.
+     */
+    private int profileDataQueryBatchSize = 100;
     /**
      * The default analyzer for match query field. {@link 
ElasticSearch.MatchQuery.AnalyzerType#OAP_ANALYZER}
      *
diff --git 
a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/NetworkAddressAliasEsDAO.java
 
b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/NetworkAddressAliasEsDAO.java
index 402ce4c720..95cd462962 100644
--- 
a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/NetworkAddressAliasEsDAO.java
+++ 
b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/NetworkAddressAliasEsDAO.java
@@ -62,9 +62,9 @@ public class NetworkAddressAliasEsDAO extends EsDAO 
implements INetworkAddressAl
 
             SearchResponse results =
                 getClient().search(NetworkAddressAlias.INDEX_NAME, search, 
params);
-            while (true) {
-                final String scrollId = results.getScrollId();
-                try {
+            final String scrollId = results.getScrollId();
+            try {
+                while (true) {
                     if (results.getHits().getTotal() == 0) {
                         break;
                     }
@@ -80,9 +80,9 @@ public class NetworkAddressAliasEsDAO extends EsDAO 
implements INetworkAddressAl
                         break;
                     }
                     results = getClient().scroll(SCROLL_CONTEXT_RETENTION, 
scrollId);
-                } finally {
-                    getClient().deleteScrollContextQuietly(scrollId);
                 }
+            } finally {
+                getClient().deleteScrollContextQuietly(scrollId);
             }
         } catch (Throwable t) {
             log.error(t.getMessage(), t);
diff --git 
a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/EBPFProfilingDataEsDAO.java
 
b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/EBPFProfilingDataEsDAO.java
index b10575da74..c638d082b2 100644
--- 
a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/EBPFProfilingDataEsDAO.java
+++ 
b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/EBPFProfilingDataEsDAO.java
@@ -43,7 +43,7 @@ public class EBPFProfilingDataEsDAO extends EsDAO implements 
IEBPFProfilingDataD
 
     public EBPFProfilingDataEsDAO(ElasticSearchClient client, 
StorageModuleElasticsearchConfig config) {
         super(client);
-        this.scrollingBatchSize = config.getScrollingBatchSize();
+        this.scrollingBatchSize = config.getProfileDataQueryBatchSize();
     }
 
     @Override
@@ -59,9 +59,9 @@ public class EBPFProfilingDataEsDAO extends EsDAO implements 
IEBPFProfilingDataD
         final List<EBPFProfilingDataRecord> records = new ArrayList<>();
 
         SearchResponse results = getClient().search(index, search.build(), 
params);
-        while (true) {
-            final String scrollId = results.getScrollId();
-            try {
+        final String scrollId = results.getScrollId();
+        try {
+            while (true) {
                 if (results.getHits().getTotal() == 0) {
                     break;
                 }
@@ -72,9 +72,9 @@ public class EBPFProfilingDataEsDAO extends EsDAO implements 
IEBPFProfilingDataD
                     break;
                 }
                 results = getClient().scroll(SCROLL_CONTEXT_RETENTION, 
scrollId);
-            } finally {
-                getClient().deleteScrollContextQuietly(scrollId);
             }
+        } finally {
+            getClient().deleteScrollContextQuietly(scrollId);
         }
         return records;
     }
diff --git 
a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetadataQueryEsDAO.java
 
b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetadataQueryEsDAO.java
index 08eb75b428..567e265585 100644
--- 
a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetadataQueryEsDAO.java
+++ 
b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetadataQueryEsDAO.java
@@ -93,9 +93,9 @@ public class MetadataQueryEsDAO extends EsDAO implements 
IMetadataQueryDAO {
         final List<Service> services = new ArrayList<>();
 
         SearchResponse results = getClient().search(index, search.build(), 
params);
-        while (true) {
-            final String scrollId = results.getScrollId();
-            try {
+        String scrollId = results.getScrollId();
+        try {
+            while (true) {
                 if (results.getHits().getTotal() == 0) {
                     break;
                 }
@@ -110,9 +110,9 @@ public class MetadataQueryEsDAO extends EsDAO implements 
IMetadataQueryDAO {
                     break;
                 }
                 results = getClient().scroll(SCROLL_CONTEXT_RETENTION, 
scrollId);
-            } finally {
-                getClient().deleteScrollContextQuietly(scrollId);
             }
+        } finally {
+            getClient().deleteScrollContextQuietly(scrollId);
         }
         return services;
     }

Reply via email to