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
commit 5ca0b43e3a0f81c2c64991536040829fb253cab9 Author: yiguolei <[email protected]> AuthorDate: Wed Apr 17 14:42:47 2024 +0800 [enhancement](auditlog) ignore any errors in write audit log (#33750) --- .../main/java/org/apache/doris/qe/AuditLogHelper.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java b/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java index 9311b4ca8e8..f88133e23a6 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java @@ -33,11 +33,27 @@ import org.apache.doris.qe.QueryState.MysqlStateType; import org.apache.doris.service.FrontendOptions; import org.apache.commons.codec.digest.DigestUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; public class AuditLogHelper { + private static final Logger LOG = LogManager.getLogger(AuditLogHelper.class); + + // Add a new method to wrap original logAuditLog to catch all exceptions. Because write audit + // log may write to a doris internal table, we may meet errors. We do not want this affect the + // query process. Ignore this error and just write warning log. public static void logAuditLog(ConnectContext ctx, String origStmt, StatementBase parsedStmt, org.apache.doris.proto.Data.PQueryStatistics statistics, boolean printFuzzyVariables) { + try { + logAuditLogImpl(ctx, origStmt, parsedStmt, statistics, printFuzzyVariables); + } catch (Throwable t) { + LOG.warn("Failed to write audit log.", t); + } + } + + private static void logAuditLogImpl(ConnectContext ctx, String origStmt, StatementBase parsedStmt, + org.apache.doris.proto.Data.PQueryStatistics statistics, boolean printFuzzyVariables) { origStmt = origStmt.replace("\n", " "); // slow query long endTime = System.currentTimeMillis(); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
