From 789999954598868a143b27e0e6a288fdd4358143 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 23 Dec 2024 17:43:42 +0800 Subject: [PATCH] Fix auditlog NPE --- .../src/main/java/org/apache/doris/qe/AuditLogHelper.java | 6 +++--- .../doris/statistics/ColumnStatisticsCacheLoader.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) 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 7f51294054d22a..2694660330b5ef 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 @@ -215,7 +215,7 @@ private static void logAuditLogImpl(ConnectContext ctx, String origStmt, Stateme .setCommandType(ctx.getCommand().toString()); if (ctx.getState().isQuery()) { - if (!ctx.getSessionVariable().internalSession) { + if (!ctx.getSessionVariable().internalSession && MetricRepo.isInit) { MetricRepo.COUNTER_QUERY_ALL.increase(1L); MetricRepo.USER_COUNTER_QUERY_ALL.getOrAdd(ctx.getQualifiedUser()).increase(1L); } @@ -231,7 +231,7 @@ private static void logAuditLogImpl(ConnectContext ctx, String origStmt, Stateme if (ctx.getState().getStateType() == MysqlStateType.ERR && ctx.getState().getErrType() != QueryState.ErrType.ANALYSIS_ERR) { // err query - if (!ctx.getSessionVariable().internalSession) { + if (!ctx.getSessionVariable().internalSession && MetricRepo.isInit) { MetricRepo.COUNTER_QUERY_ERR.increase(1L); MetricRepo.USER_COUNTER_QUERY_ERR.getOrAdd(ctx.getQualifiedUser()).increase(1L); MetricRepo.increaseClusterQueryErr(cloudCluster); @@ -239,7 +239,7 @@ private static void logAuditLogImpl(ConnectContext ctx, String origStmt, Stateme } else if (ctx.getState().getStateType() == MysqlStateType.OK || ctx.getState().getStateType() == MysqlStateType.EOF) { // ok query - if (!ctx.getSessionVariable().internalSession) { + if (!ctx.getSessionVariable().internalSession && MetricRepo.isInit) { MetricRepo.HISTO_QUERY_LATENCY.update(elapseMs); MetricRepo.USER_HISTO_QUERY_LATENCY.getOrAdd(ctx.getQualifiedUser()).update(elapseMs); MetricRepo.updateClusterQueryLatency(cloudCluster, elapseMs); diff --git a/fe/fe-core/src/main/java/org/apache/doris/statistics/ColumnStatisticsCacheLoader.java b/fe/fe-core/src/main/java/org/apache/doris/statistics/ColumnStatisticsCacheLoader.java index 692d723ed0a9f5..8e29fe25d72574 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/statistics/ColumnStatisticsCacheLoader.java +++ b/fe/fe-core/src/main/java/org/apache/doris/statistics/ColumnStatisticsCacheLoader.java @@ -42,7 +42,7 @@ protected Optional doLoad(StatisticsCacheKey key) { columnStatistic = table.getColumnStatistic(key.colName); } } catch (Throwable t) { - LOG.warn("Failed to load stats for column [Catalog:{}, DB:{}, Table:{}, Column:{}], Reason: {}", + LOG.info("Failed to load stats for column [Catalog:{}, DB:{}, Table:{}, Column:{}], Reason: {}", key.catalogId, key.dbId, key.tableId, key.colName, t.getMessage()); if (LOG.isDebugEnabled()) { LOG.debug(t);