You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ke...@apache.org on 2021/05/31 07:59:56 UTC

[skywalking] branch exporter created (now d40ceb1)

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

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


      at d40ceb1  Make metrics exporter still work even when storage layer failed

This branch includes the following new commits:

     new d40ceb1  Make metrics exporter still work even when storage layer failed

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: Make metrics exporter still work even when storage layer failed

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

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

commit d40ceb1c4061c4b38b69b7c644a5419156e673d1
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Mon May 31 15:59:25 2021 +0800

    Make metrics exporter still work even when storage layer failed
---
 CHANGES.md                                         |  3 ++-
 .../analysis/worker/MetricsPersistentWorker.java   | 25 ++++++++++++++--------
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 8074eda..8157501 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -32,7 +32,7 @@ Release Notes.
 * Introduce method interceptor API v2
 * Fix ClassCast issue for RequestHolder/ResponseHolder.
 * fixed `jdk-threading-plugin` memory leak.
-* Optimize multiple field reflection opeartion in Fiegn plugin.
+* Optimize multiple field reflection operation in Feign plugin.
 
 #### OAP-Backend
 * BugFix: filter invalid Envoy access logs whose socket address is empty.
@@ -57,6 +57,7 @@ Release Notes.
 * Events can be configured as alarm source.
 * Make the number of core worker in meter converter thread pool configurable.
 * Add HTTP implementation of logs reporting protocol.
+* Make metrics exporter still work even when storage layer failed.
 
 #### UI
 * Add logo for kong plugin.
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsPersistentWorker.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsPersistentWorker.java
index f750e7c..8f5f407 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsPersistentWorker.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsPersistentWorker.java
@@ -209,16 +209,23 @@ public class MetricsPersistentWorker extends PersistenceWorker<Metrics> {
     /**
      * Load data from the storage, if {@link #enableDatabaseSession} == true, only load data when the id doesn't exist.
      */
-    private void loadFromStorage(List<Metrics> metrics) throws IOException {
-        if (!enableDatabaseSession) {
-            context.clear();
-        }
+    private void loadFromStorage(List<Metrics> metrics) {
+        try {
+            List<Metrics> noInCacheMetrics = metrics.stream()
+                                                    .filter(m -> !context.containsKey(m) || !enableDatabaseSession)
+                                                    .collect(Collectors.toList());
+            if (noInCacheMetrics.isEmpty()) {
+                return;
+            }
 
-        List<Metrics> noInCacheMetrics = metrics.stream()
-                                                .filter(m -> !context.containsKey(m))
-                                                .collect(Collectors.toList());
-        if (!noInCacheMetrics.isEmpty()) {
-            metricsDAO.multiGet(model, noInCacheMetrics).forEach(m -> context.put(m, m));
+            final List<Metrics> dbMetrics = metricsDAO.multiGet(model, noInCacheMetrics);
+            if (!enableDatabaseSession) {
+                // Clear the cache only after results from DB are returned successfully.
+                context.clear();
+            }
+            dbMetrics.forEach(m -> context.put(m, m));
+        } catch (final Exception e) {
+            log.error("Failed to load metrics for merging", e);
         }
     }