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 2022/12/07 14:03:36 UTC

[skywalking] branch refresh created (now e649edf785)

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

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


      at e649edf785 use `core/persistentPeriod` + 5s as `refresh_interval` for all indices

This branch includes the following new commits:

     new e649edf785 use `core/persistentPeriod` + 5s as `refresh_interval` for all indices

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: use `core/persistentPeriod` + 5s as `refresh_interval` for all indices

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

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

commit e649edf785902e78748133ad4b717839177ec534
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Wed Dec 7 22:03:21 2022 +0800

    use `core/persistentPeriod` + 5s as `refresh_interval` for all indices
---
 docs/en/changes/changes.md                                |  2 ++
 docs/en/setup/backend/configuration-vocabulary.md         |  2 +-
 .../skywalking/oap/server/core/CoreModuleConfig.java      |  2 +-
 .../skywalking/oap/server/core/config/ConfigService.java  |  2 ++
 .../server-starter/src/main/resources/application.yml     |  3 +--
 .../elasticsearch/StorageModuleElasticsearchConfig.java   |  3 ---
 .../elasticsearch/StorageModuleElasticsearchProvider.java |  8 +++++++-
 .../plugin/elasticsearch/base/StorageEsInstaller.java     | 15 +++------------
 8 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md
index 0bf4669869..804fb0b8f9 100644
--- a/docs/en/changes/changes.md
+++ b/docs/en/changes/changes.md
@@ -29,6 +29,8 @@
 * Remove abandon logic in MergableBufferedData, which caused unexpected no-update.
 * Fix miss set `LastUpdateTimestamp` that caused the metrics session to expire.
 * Rename MAL rule `spring-sleuth.yaml` to `spring-micrometer.yaml`.
+* Remove the dependency of `refresh_interval` of ElasticSearch indices from `elasticsearch/flushInterval` config. Now,
+  it uses `core/persistentPeriod` + 5s as `refresh_interval` for all indices instead.
 
 #### UI
 
diff --git a/docs/en/setup/backend/configuration-vocabulary.md b/docs/en/setup/backend/configuration-vocabulary.md
index acfefe90a9..0906e334c0 100644
--- a/docs/en/setup/backend/configuration-vocabulary.md
+++ b/docs/en/setup/backend/configuration-vocabulary.md
@@ -105,7 +105,7 @@ The Configuration Vocabulary lists all available configurations provided by `app
 | -                       | -             | superDatasetIndexReplicasNumber                                                                                                                                          | Represents the replicas number in the super size dataset record index.                                                                                                                                                                                                                [...]
 | -                       | -             | indexTemplateOrder                                                                                                                                                       | The order of index template.                                                                                                                                                                                                                                                          [...]
 | -                       | -             | bulkActions                                                                                                                                                              | Async bulk size of the record data batch execution.                                                                                                                                                                                                                                   [...]
-| -                       | -             | flushInterval                                                                                                                                                            | Period of flush (in seconds). Does not matter whether `bulkActions` is reached or not. INT(flushInterval * 2/3) is used for index refresh period.                                                                                                                                     [...]
+| -                       | -             | flushInterval                                                                                                                                                            | Period of flush (in seconds). Does not matter whether `bulkActions` is reached or not.                                                                                                                                                                                                [...]
 | -                       | -             | concurrentRequests                                                                                                                                                       | The number of concurrent requests allowed to be executed.                                                                                                                                                                                                                             [...]
 | -                       | -             | resultWindowMaxSize                                                                                                                                                      | The maximum size of dataset when the OAP loads cache, such as network aliases.                                                                                                                                                                                                        [...]
 | -                       | -             | metadataQueryMaxSize                                                                                                                                                     | The maximum size of metadata per query.                                                                                                                                                                                                                                               [...]
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleConfig.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleConfig.java
index c58a49d821..3e1d4e63a4 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleConfig.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleConfig.java
@@ -58,7 +58,7 @@ public class CoreModuleConfig extends ModuleConfig {
      * The period of doing data persistence. Unit is second.
      */
     @Setter
-    private long persistentPeriod = 25;
+    private int persistentPeriod = 25;
 
     private boolean enableDataKeeperExecutor = true;
 
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/config/ConfigService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/config/ConfigService.java
index 0ab72c0bf7..b6d36553d2 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/config/ConfigService.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/config/ConfigService.java
@@ -31,6 +31,7 @@ public class ConfigService implements Service {
     private final String searchableAlarmTags;
     private final int metricsDataTTL;
     private final int recordDataTTL;
+    private final int persistentPeriod;
 
     public ConfigService(CoreModuleConfig moduleConfig) {
         this.gRPCHost = moduleConfig.getGRPCHost();
@@ -40,5 +41,6 @@ public class ConfigService implements Service {
         this.searchableAlarmTags = moduleConfig.getSearchableAlarmTags();
         this.metricsDataTTL = moduleConfig.getMetricsDataTTL();
         this.recordDataTTL = moduleConfig.getRecordDataTTL();
+        this.persistentPeriod = moduleConfig.getPersistentPeriod();
     }
 }
diff --git a/oap-server/server-starter/src/main/resources/application.yml b/oap-server/server-starter/src/main/resources/application.yml
index b4e507dc30..1ae00a3896 100644
--- a/oap-server/server-starter/src/main/resources/application.yml
+++ b/oap-server/server-starter/src/main/resources/application.yml
@@ -156,8 +156,7 @@ storage:
     superDatasetIndexReplicasNumber: ${SW_STORAGE_ES_SUPER_DATASET_INDEX_REPLICAS_NUMBER:0} # Represent the replicas number in the super size dataset record index, the default value is 0.
     indexTemplateOrder: ${SW_STORAGE_ES_INDEX_TEMPLATE_ORDER:0} # the order of index template
     bulkActions: ${SW_STORAGE_ES_BULK_ACTIONS:5000} # Execute the async bulk record data every ${SW_STORAGE_ES_BULK_ACTIONS} requests
-    # flush the bulk every 10 seconds whatever the number of requests
-    # INT(flushInterval * 2/3) would be used for index refresh period.
+    # flush the bulk every 15 seconds whatever the number of requests
     flushInterval: ${SW_STORAGE_ES_FLUSH_INTERVAL:15}
     concurrentRequests: ${SW_STORAGE_ES_CONCURRENT_REQUESTS:2} # the number of concurrent requests
     resultWindowMaxSize: ${SW_STORAGE_ES_QUERY_MAX_WINDOW_SIZE:10000}
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 ac5f5b4c7f..21db90470c 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
@@ -92,9 +92,6 @@ public class StorageModuleElasticsearchConfig extends ModuleConfig {
      * Period of flush, no matter `bulkActions` reached or not.
      * INT(flushInterval * 2/3) would be used for index refresh period.
      * Unit is second.
-     *
-     * @since 8.7.0 increase to 15s from 10s
-     * @since 8.7.0 use INT(flushInterval * 2/3) as ElasticSearch index refresh interval. Default is 10s.
      */
     private int flushInterval = 15;
     private int concurrentRequests = 2;
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchProvider.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchProvider.java
index da52561c7d..84e5b1eb41 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchProvider.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchProvider.java
@@ -23,6 +23,7 @@ import java.util.Properties;
 import java.util.function.Function;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.skywalking.oap.server.core.CoreModule;
+import org.apache.skywalking.oap.server.core.config.ConfigService;
 import org.apache.skywalking.oap.server.core.storage.IBatchDAO;
 import org.apache.skywalking.oap.server.core.storage.IHistoryDeleteDAO;
 import org.apache.skywalking.oap.server.core.storage.StorageBuilderFactory;
@@ -100,7 +101,7 @@ public class StorageModuleElasticsearchProvider extends ModuleProvider {
 
     protected StorageModuleElasticsearchConfig config;
     protected ElasticSearchClient elasticSearchClient;
-    protected ModelInstaller modelInstaller;
+    protected StorageEsInstaller modelInstaller;
 
     @Override
     public String name() {
@@ -243,6 +244,11 @@ public class StorageModuleElasticsearchProvider extends ModuleProvider {
         elasticSearchClient.registerChecker(healthChecker);
         try {
             elasticSearchClient.connect();
+
+            final ConfigService service = getManager().find(CoreModule.NAME).provider().getService(ConfigService.class);
+            // Add 5s to make sure OAP has at least done persistent once.
+            // By default, the persistent period is 25 seconds and ElasticSearch refreshes in every 30 seconds.
+            modelInstaller.setIndexRefreshInterval(service.getPersistentPeriod() + 5);
             modelInstaller.start();
 
             getManager().find(CoreModule.NAME).provider().getService(ModelCreator.class).addModelListener(modelInstaller);
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 f5345a6c27..c3f9bd4619 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
@@ -26,6 +26,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
+import lombok.Setter;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.skywalking.library.elasticsearch.response.Index;
 import org.apache.skywalking.library.elasticsearch.response.IndexTemplate;
@@ -49,6 +50,8 @@ public class StorageEsInstaller extends ModelInstaller {
     private final StorageModuleElasticsearchConfig config;
     protected final ColumnTypeEsMapping columnTypeEsMapping;
     private final Map<String, Map<String, Object>> specificIndexesSettings;
+    @Setter
+    private int indexRefreshInterval = 30;
 
     /**
      * The mappings of the template .
@@ -236,18 +239,6 @@ public class StorageEsInstaller extends ModelInstaller {
         indexSettings.put("number_of_shards", model.isSuperDataset()
             ? Integer.toString(config.getIndexShardsNumber() * config.getSuperDatasetIndexShardsFactor())
             : Integer.toString(config.getIndexShardsNumber()));
-        // Set the index refresh period as INT(flushInterval * 2/3). At the edge case,
-        // in low traffic(traffic < bulkActions in the whole period), there is a possible case, 2 period bulks are included in
-        // one index refresh rebuild operation, which could cause version conflicts. And this case can't be fixed
-        // through `core/persistentPeriod` as the bulk fresh is not controlled by the persistent timer anymore.
-        int indexRefreshInterval = config.getFlushInterval() * 2 / 3;
-        if (indexRefreshInterval < 5) {
-            // The refresh interval should not be less than 5 seconds (the recommended default value = 10s),
-            // and the bulk flush interval should not be set less than 8s (the recommended default value = 15s).
-            // This is a precaution case which makes ElasticSearch server has reasonable refresh interval,
-            // even this value is set too small by end user manually.
-            indexRefreshInterval = 5;
-        }
         indexSettings.put("refresh_interval", indexRefreshInterval + "s");
         indexSettings.put("analysis", getAnalyzerSetting(model));
         if (!StringUtil.isEmpty(config.getAdvanced())) {