Skip to content

Commit

Permalink
Fix auditlog NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
Jibing-Li committed Dec 23, 2024
1 parent 8f1dc58 commit 7899999
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -231,15 +231,15 @@ 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);
}
} 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected Optional<ColumnStatistic> 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);
Expand Down

0 comments on commit 7899999

Please sign in to comment.