[Fix](statistics)Fix auto job start time incorrect bug (#27402)

Before, the auto analyze job start time was the job creation time, not the start to execute time, which is inaccurate. This pr is to change the start time to the first task start to execute time.
This commit is contained in:
Jibing-Li
2023-11-22 21:38:08 +08:00
committed by GitHub
parent 3e1a5b6e29
commit 19c36dcc86
4 changed files with 67 additions and 2 deletions

View File

@ -2662,7 +2662,7 @@ public class ShowExecutor {
}
row.add(analysisInfo.scheduleType.toString());
LocalDateTime startTime =
LocalDateTime.ofInstant(Instant.ofEpochMilli(analysisInfo.createTime),
LocalDateTime.ofInstant(Instant.ofEpochMilli(analysisInfo.startTime),
java.time.ZoneId.systemDefault());
LocalDateTime endTime =
LocalDateTime.ofInstant(Instant.ofEpochMilli(analysisInfo.endTime),

View File

@ -185,6 +185,9 @@ public class AnalysisInfo implements Writable {
@SerializedName("createTime")
public final long createTime = System.currentTimeMillis();
@SerializedName("startTime")
public long startTime;
@SerializedName("endTime")
public long endTime;
/**
@ -330,6 +333,10 @@ public class AnalysisInfo implements Writable {
return analysisInfo;
}
public void markStartTime(long startTime) {
this.startTime = startTime;
}
public void markFinished() {
state = AnalysisState.FINISHED;
endTime = System.currentTimeMillis();

View File

@ -158,6 +158,7 @@ public class AnalysisManager implements Writable {
// Set the job state to RUNNING when its first task becomes RUNNING.
if (info.state.equals(AnalysisState.RUNNING) && job.state.equals(AnalysisState.PENDING)) {
job.state = AnalysisState.RUNNING;
job.markStartTime(System.currentTimeMillis());
replayCreateAnalysisJob(job);
}
boolean allFinished = true;
@ -200,6 +201,13 @@ public class AnalysisManager implements Writable {
if (job == null) {
return null;
}
synchronized (job) {
// Set the job state to RUNNING when its first task becomes RUNNING.
if (info.state.equals(AnalysisState.RUNNING) && job.state.equals(AnalysisState.PENDING)) {
job.state = AnalysisState.RUNNING;
job.markStartTime(System.currentTimeMillis());
}
}
int failedCount = 0;
StringJoiner reason = new StringJoiner(", ");
Map<Long, BaseAnalysisTask> taskMap = analysisJobIdToTaskMap.get(info.jobId);
@ -1002,7 +1010,6 @@ public class AnalysisManager implements Writable {
}
public void registerSysJob(AnalysisInfo jobInfo, Map<Long, BaseAnalysisTask> taskInfos) {
jobInfo.state = AnalysisState.RUNNING;
systemJobInfoMap.put(jobInfo.jobId, jobInfo);
analysisJobIdToTaskMap.put(jobInfo.jobId, taskInfos);
}