[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:
@ -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),
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user