Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE can occur in the Response Path if MetricRepo is not initialized yet #42505

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,10 @@ private static void logAuditLogImpl(ConnectContext ctx, String origStmt, Stateme

if (ctx.getState().isQuery()) {
if (!ctx.getSessionVariable().internalSession) {
MetricRepo.COUNTER_QUERY_ALL.increase(1L);
MetricRepo.USER_COUNTER_QUERY_ALL.getOrAdd(ctx.getQualifiedUser()).increase(1L);
if (MetricRepo.isInit) {
MetricRepo.COUNTER_QUERY_ALL.increase(1L);
MetricRepo.USER_COUNTER_QUERY_ALL.getOrAdd(ctx.getQualifiedUser()).increase(1L);
}
}
try {
if (Config.isCloudMode()) {
Expand All @@ -228,16 +230,20 @@ private static void logAuditLogImpl(ConnectContext ctx, String origStmt, Stateme
&& ctx.getState().getErrType() != QueryState.ErrType.ANALYSIS_ERR) {
// err query
if (!ctx.getSessionVariable().internalSession) {
MetricRepo.COUNTER_QUERY_ERR.increase(1L);
MetricRepo.USER_COUNTER_QUERY_ERR.getOrAdd(ctx.getQualifiedUser()).increase(1L);
if (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) {
MetricRepo.HISTO_QUERY_LATENCY.update(elapseMs);
MetricRepo.USER_HISTO_QUERY_LATENCY.getOrAdd(ctx.getQualifiedUser()).update(elapseMs);
if (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 @@ -150,7 +150,9 @@ public void registerInstances(TUniqueId queryId, Integer instancesNum) throws Us
}
queryToInstancesNum.put(queryId, instancesNum);
userToInstancesCount.computeIfAbsent(user, ignored -> new AtomicInteger(0)).addAndGet(instancesNum);
MetricRepo.USER_COUNTER_QUERY_INSTANCE_BEGIN.getOrAdd(user).increase(instancesNum.longValue());
if (MetricRepo.isInit) {
MetricRepo.USER_COUNTER_QUERY_INSTANCE_BEGIN.getOrAdd(user).increase(instancesNum.longValue());
}
}
}

Expand Down
Loading