You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tr...@apache.org on 2018/11/03 09:36:49 UTC

[flink] branch release-1.6 updated: [FLINK-10715] Suppress ConcurrnetModificationException in Slf4jReporter

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

trohrmann pushed a commit to branch release-1.6
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-1.6 by this push:
     new 246fd8e  [FLINK-10715] Suppress ConcurrnetModificationException in Slf4jReporter
246fd8e is described below

commit 246fd8e212eff48505fe037a783ed03288a4cae6
Author: Igal Shilman <ig...@data-artisans.com>
AuthorDate: Fri Nov 2 16:40:06 2018 +0100

    [FLINK-10715] Suppress ConcurrnetModificationException in Slf4jReporter
    
    This commit suppress the ConcurrentModificationException thrown by the Slf4jReporter
    report method. This exception occurs when a metric is added/removed while this report is reporting.
    Suppressing this (somewhat expected exception) is needed by our e2e framework to reduce some
    false-positive e2e test failures. This does not solves the root issue, which is being tracked in a different issue FLINK-10035.
    
    This closes #7008.
---
 .../java/org/apache/flink/metrics/slf4j/Slf4jReporter.java    | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/flink-metrics/flink-metrics-slf4j/src/main/java/org/apache/flink/metrics/slf4j/Slf4jReporter.java b/flink-metrics/flink-metrics-slf4j/src/main/java/org/apache/flink/metrics/slf4j/Slf4jReporter.java
index 124efe2..ce6acb0 100644
--- a/flink-metrics/flink-metrics-slf4j/src/main/java/org/apache/flink/metrics/slf4j/Slf4jReporter.java
+++ b/flink-metrics/flink-metrics-slf4j/src/main/java/org/apache/flink/metrics/slf4j/Slf4jReporter.java
@@ -33,6 +33,7 @@ import org.apache.flink.metrics.reporter.Scheduled;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.ConcurrentModificationException;
 import java.util.Map;
 
 /**
@@ -75,6 +76,16 @@ public class Slf4jReporter extends AbstractReporter implements Scheduled {
 
 	@Override
 	public void report() {
+		try {
+			tryReport();
+		}
+		catch (ConcurrentModificationException ignored) {
+			// at tryReport() we don't synchronize while iterating over the various maps which might cause a
+			// ConcurrentModificationException to be thrown, if concurrently a metric is being added or removed.
+		}
+	}
+
+	private void tryReport() {
 		// initialize with previous size to avoid repeated resizing of backing array
 		// pad the size to allow deviations in the final string, for example due to different double value representations
 		StringBuilder builder = new StringBuilder((int) (previousSize * 1.1));