This is an automated email from the ASF dual-hosted git repository.
mapohl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/master by this push:
new 49146cdec41 [FLINK-30299][core] Adds thread dump creation to
FatalExitExceptionHandler
49146cdec41 is described below
commit 49146cdec41467445de5fc81f100585142728bdf
Author: Matthias Pohl <[email protected]>
AuthorDate: Wed Dec 7 16:57:25 2022 +0100
[FLINK-30299][core] Adds thread dump creation to FatalExitExceptionHandler
Signed-off-by: Matthias Pohl <[email protected]>
---
.../flink/util/FatalExitExceptionHandler.java | 2 ++
.../apache/flink/util/concurrent/ThreadUtils.java | 38 ++++++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git
a/flink-core/src/main/java/org/apache/flink/util/FatalExitExceptionHandler.java
b/flink-core/src/main/java/org/apache/flink/util/FatalExitExceptionHandler.java
index 8ff0e9b7b0a..35b0d733247 100644
---
a/flink-core/src/main/java/org/apache/flink/util/FatalExitExceptionHandler.java
+++
b/flink-core/src/main/java/org/apache/flink/util/FatalExitExceptionHandler.java
@@ -19,6 +19,7 @@
package org.apache.flink.util;
import org.apache.flink.core.security.FlinkSecurityManager;
+import org.apache.flink.util.concurrent.ThreadUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -43,6 +44,7 @@ public final class FatalExitExceptionHandler implements
Thread.UncaughtException
"FATAL: Thread '{}' produced an uncaught exception.
Stopping the process...",
t.getName(),
e);
+ ThreadUtils.errorLogThreadDump(LOG);
} finally {
FlinkSecurityManager.forceProcessExit(EXIT_CODE);
}
diff --git
a/flink-core/src/main/java/org/apache/flink/util/concurrent/ThreadUtils.java
b/flink-core/src/main/java/org/apache/flink/util/concurrent/ThreadUtils.java
new file mode 100644
index 00000000000..35e3c604f22
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/util/concurrent/ThreadUtils.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.util.concurrent;
+
+import org.slf4j.Logger;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.ThreadInfo;
+import java.util.Arrays;
+import java.util.stream.Collectors;
+
+/** {@code ThreadUtils} collects helper methods in the context of threading. */
+public class ThreadUtils {
+
+ public static void errorLogThreadDump(Logger logger) {
+ final ThreadInfo[] perThreadInfo =
+ ManagementFactory.getThreadMXBean().dumpAllThreads(true, true);
+ logger.error(
+ "Thread dump: \n{}",
+
Arrays.stream(perThreadInfo).map(Object::toString).collect(Collectors.joining()));
+ }
+}