This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push: new 2eed4f3a65f branch-2.1: [opt](paimon)Add suppressed information display #48947 (#48997) 2eed4f3a65f is described below commit 2eed4f3a65f2ca9bcf3e94f06bac2856199a9eb4 Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> AuthorDate: Sat Mar 22 07:42:45 2025 +0800 branch-2.1: [opt](paimon)Add suppressed information display #48947 (#48997) Cherry-picked from #48947 Co-authored-by: wuwenchi <wuwen...@selectdb.com> --- .../java/org/apache/doris/common/util/Util.java | 20 +++++ .../java/org/apache/doris/qe/StmtExecutor.java | 2 +- .../org/apache/doris/common/util/UtilTest.java | 86 ++++++++++++++++++++++ 3 files changed, 107 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/Util.java b/fe/fe-core/src/main/java/org/apache/doris/common/util/Util.java index 3ed0b0864e1..78462f3a6ad 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/util/Util.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/Util.java @@ -643,6 +643,26 @@ public class Util { return rootCause; } + public static String getRootCauseWithSuppressedMessage(Throwable t) { + String rootCause; + Throwable p = t; + while (p.getCause() != null) { + p = p.getCause(); + } + String message = p.getMessage(); + if (message == null) { + rootCause = p.getClass().getName(); + } else { + rootCause = p.getClass().getName() + ": " + p.getMessage(); + } + StringBuilder msg = new StringBuilder(rootCause); + Throwable[] suppressed = p.getSuppressed(); + for (int i = 0; i < suppressed.length; i++) { + msg.append(" With suppressed").append("[").append(i).append("]:").append(suppressed[i].getMessage()); + } + return msg.toString(); + } + // Return the stack of the root cause public static String getRootCauseStack(Throwable t) { String rootStack = "unknown"; diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java index 248290226eb..8f1a6036950 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java @@ -1034,7 +1034,7 @@ public class StmtExecutor { } catch (Exception e) { LOG.warn("execute Exception. {}", context.getQueryIdentifier(), e); context.getState().setError(ErrorCode.ERR_UNKNOWN_ERROR, - e.getClass().getSimpleName() + ", msg: " + Util.getRootCauseMessage(e)); + e.getClass().getSimpleName() + ", msg: " + Util.getRootCauseWithSuppressedMessage(e)); if (parsedStmt instanceof KillStmt) { // ignore kill stmt execute err(not monitor it) context.getState().setErrType(QueryState.ErrType.ANALYSIS_ERR); diff --git a/fe/fe-core/src/test/java/org/apache/doris/common/util/UtilTest.java b/fe/fe-core/src/test/java/org/apache/doris/common/util/UtilTest.java new file mode 100644 index 00000000000..1f88cf5a662 --- /dev/null +++ b/fe/fe-core/src/test/java/org/apache/doris/common/util/UtilTest.java @@ -0,0 +1,86 @@ +// 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.doris.common.util; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class UtilTest { + + @Test + public void getRootCauseWithSuppressedMessageRootCauseWithMessageNoSuppressed() { + Exception rootCause = new Exception("Root cause message"); + Assertions.assertEquals("java.lang.Exception: Root cause message", + Util.getRootCauseWithSuppressedMessage(rootCause)); + } + + @Test + public void getRootCauseWithSuppressedMessageRootCauseWithMessageWithSuppressed() { + Exception rootCause = new Exception("Root cause message"); + rootCause.addSuppressed(new Exception("Suppressed message")); + Assertions.assertEquals( + "java.lang.Exception: Root cause message With suppressed[0]:Suppressed message", + Util.getRootCauseWithSuppressedMessage(rootCause)); + } + + @Test + public void getRootCauseWithSuppressedMessageRootCauseWithMessageWithMultiSuppressed() { + Exception rootCause = new Exception("Root cause message"); + rootCause.addSuppressed(new Exception("Suppressed message")); + rootCause.addSuppressed(new Exception("Suppressed message2")); + Assertions.assertEquals( + "java.lang.Exception: Root cause message" + + " With suppressed[0]:Suppressed message" + + " With suppressed[1]:Suppressed message2", + Util.getRootCauseWithSuppressedMessage(rootCause)); + } + + @Test + public void getRootCauseWithSuppressedMessageRootCauseWithoutMessageNoSuppressed() { + Exception rootCause = new Exception(); + Assertions.assertEquals("java.lang.Exception", Util.getRootCauseWithSuppressedMessage(rootCause)); + } + + @Test + public void getRootCauseWithSuppressedMessageRootCauseWithoutMessageWithSuppressed() { + Exception rootCause = new Exception(); + rootCause.addSuppressed(new Exception("Suppressed message")); + Assertions.assertEquals( + "java.lang.Exception With suppressed[0]:Suppressed message", + Util.getRootCauseWithSuppressedMessage(rootCause)); + } + + @Test + public void getRootCauseWithSuppressedMessageChainedExceptionWithChainedSuppressed() { + Exception rootCause = new Exception("Root cause message"); + Exception chainedException = new Exception("Chained exception", rootCause); + chainedException.addSuppressed(new Exception("Suppressed message")); + Assertions.assertEquals("java.lang.Exception: Root cause message", + Util.getRootCauseWithSuppressedMessage(chainedException)); + } + + @Test + public void getRootCauseWithSuppressedMessageChainedExceptionWithCauseSuppressed() { + Exception rootCause = new Exception("Root cause message"); + Exception chainedException = new Exception("Chained exception", rootCause); + rootCause.addSuppressed(new Exception("Suppressed message")); + Assertions.assertEquals( + "java.lang.Exception: Root cause message With suppressed[0]:Suppressed message", + Util.getRootCauseWithSuppressedMessage(chainedException)); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org