From 68fff61dbf295c46dbe5a4a2cc69c28d33d8dd13 Mon Sep 17 00:00:00 2001 From: peacewong Date: Fri, 13 May 2022 19:36:47 +0800 Subject: [PATCH] release 1.1.2 --- .../entrance/timeout/JobTimeoutManager.scala | 25 +++++++++++-------- .../manager/dao/impl/LabelManagerMapper.xml | 3 +-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/timeout/JobTimeoutManager.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/timeout/JobTimeoutManager.scala index 3c14ec211f..b9ec38941f 100644 --- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/timeout/JobTimeoutManager.scala +++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/timeout/JobTimeoutManager.scala @@ -75,21 +75,24 @@ class JobTimeoutManager extends Logging { private def timeoutDetective(): Unit = { if (timeoutCheck) { def checkAndSwitch(job: EntranceJob): Unit = { - info(s"Checking whether the job timed out: ${job.getId()}") - val currentTime = System.currentTimeMillis() / 1000 - val queuingTime = currentTime - job.getScheduledTime / 1000 - val runningTime = currentTime - job.getStartTime / 1000 + info(s"Checking whether the job id ${job.getJobRequest.getId()} timed out. ") + val currentTimeSeconds = System.currentTimeMillis() / 1000 + // job.isWaiting == job in queue + val jobScheduleStartTimeSeconds = if (job.isWaiting) job.createTime / 1000 else currentTimeSeconds + val queuingTimeSeconds = currentTimeSeconds - jobScheduleStartTimeSeconds + val jobRunningStartTimeSeconds = if (job.getStartTime > 0) job.getStartTime / 1000 else currentTimeSeconds + val runningTimeSeconds = currentTimeSeconds - jobRunningStartTimeSeconds if (!job.isCompleted) { job.jobRequest.getLabels foreach { case queueTimeOutLabel: JobQueuingTimeoutLabel => - if (queueTimeOutLabel.getQueuingTimeout > 0 && queuingTime >= queueTimeOutLabel.getQueuingTimeout) { - warn(s"Job queuing timeout, cancel it now: ${job.getId()}") - job.cancel() + if (job.isWaiting && queueTimeOutLabel.getQueuingTimeout > 0 && queuingTimeSeconds >= queueTimeOutLabel.getQueuingTimeout) { + logger.warn(s"Job ${job.getJobRequest.getId()} queued time : ${queuingTimeSeconds} seconds, which was over queueTimeOut : ${queueTimeOutLabel.getQueuingTimeout} seconds, cancel it now! ") + job.onFailure(s"Job queued ${queuingTimeSeconds} seconds over max queue time : ${queueTimeOutLabel.getQueuingTimeout} seconds.", null) } case jobRunningTimeoutLabel: JobRunningTimeoutLabel => - if (jobRunningTimeoutLabel.getRunningTimeout > 0 && runningTime >= jobRunningTimeoutLabel.getRunningTimeout) { - warn(s"Job running timeout, cancel it now: ${job.getId()}") - job.cancel() + if (job.isRunning && jobRunningTimeoutLabel.getRunningTimeout > 0 && runningTimeSeconds >= jobRunningTimeoutLabel.getRunningTimeout) { + logger.warn(s"Job ${job.getJobRequest.getId()} run timeout ${runningTimeSeconds} seconds, which was over runTimeOut : ${jobRunningTimeoutLabel.getRunningTimeout} seconds, cancel it now! ") + job.onFailure(s"Job run ${runningTimeSeconds} seconds over max run time : ${jobRunningTimeoutLabel.getRunningTimeout} seconds.", null) } case _ => } @@ -97,7 +100,7 @@ class JobTimeoutManager extends Logging { } timeoutJobByName.foreach(item => { - info(s"Running timeout detection!") + logger.info(s"Running timeout detection!") synchronized { jobCompleteDelete(item._1) if (jobExist(item._1)) checkAndSwitch(item._2) diff --git a/linkis-computation-governance/linkis-manager/linkis-manager-persistence/src/main/java/org/apache/linkis/manager/dao/impl/LabelManagerMapper.xml b/linkis-computation-governance/linkis-manager/linkis-manager-persistence/src/main/java/org/apache/linkis/manager/dao/impl/LabelManagerMapper.xml index cbbd6d4621..41ef43e34a 100644 --- a/linkis-computation-governance/linkis-manager/linkis-manager-persistence/src/main/java/org/apache/linkis/manager/dao/impl/LabelManagerMapper.xml +++ b/linkis-computation-governance/linkis-manager/linkis-manager-persistence/src/main/java/org/apache/linkis/manager/dao/impl/LabelManagerMapper.xml @@ -83,8 +83,7 @@ - INSERT INTO linkis_cg_manager_label_value_relation (label_value_key,label_value_content,label_id,update_time,create_time) VALUES(#{labelKey}, #{labelStringValue},#{labelId},now(),now()) - ON DUPLICATE KEY UPDATE label_value_content=#{labelStringValue},update_time=now() + REPLACE INTO linkis_cg_manager_label_value_relation (label_value_key,label_value_content,label_id,update_time,create_time) VALUES(#{labelKey}, #{labelStringValue},#{labelId},now(),now())