From 10e4b887dee3d747611f112a352579d60be49c2a Mon Sep 17 00:00:00 2001 From: ysCha Date: Fri, 6 Feb 2026 14:33:59 +0900 Subject: [PATCH] =?UTF-8?q?job=20=EB=A1=9C=EA=B7=B8=20=EC=B6=94=EA=B0=80(?= =?UTF-8?q?=EC=97=90=EB=9F=AC=ED=99=95=EC=9D=B8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qcast/batch/JobLauncherController.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main/java/com/interplug/qcast/batch/JobLauncherController.java b/src/main/java/com/interplug/qcast/batch/JobLauncherController.java index 4d1503e7..483decf8 100644 --- a/src/main/java/com/interplug/qcast/batch/JobLauncherController.java +++ b/src/main/java/com/interplug/qcast/batch/JobLauncherController.java @@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; import org.springframework.context.event.EventListener; import java.time.LocalDateTime; +import java.sql.SQLException; @RestController @RequiredArgsConstructor @@ -74,6 +75,7 @@ public class JobLauncherController { JobParametersInvalidException, JobRestartException { + log.info("Manual launch requested for job: {}", jobName); Job job = jobs.get(jobName); Map resultMap = new HashMap(); if (job == null) { @@ -98,6 +100,7 @@ public class JobLauncherController { .addDate("time", new Date()).toJobParameters(); JobExecution jobExecution = jobLauncher.run(job, jobParameters); + log.info("Job {} started with execution id {}", jobName, jobExecution.getId()); BatchStatus status = jobExecution.getStatus(); ExitStatus exitStatus = jobExecution.getExitStatus(); @@ -108,6 +111,7 @@ public class JobLauncherController { // return "Job " + jobName + " started"; return resultMap; } catch (Exception e) { + logExceptionDetails("Manual launch failed", jobName, e); resultMap.put("code", "FAILED"); resultMap.put("message", e.getMessage()); return resultMap; @@ -302,12 +306,14 @@ public class JobLauncherController { log.info("Job {} 실행 시도 (재시도 {}/{})", jobName, retryCount + 1, maxRetries); JobExecution jobExecution = jobLauncher.run(job, jobParameters); + log.info("Job {} started with execution id {}", jobName, jobExecution.getId()); log.info("Job {} 완료 상태: {}", jobName, jobExecution.getExitStatus().getExitCode()); return jobName + " executed successfully"; } catch (Exception e) { retryCount++; + logExceptionDetails("Scheduled launch failed", jobName, e); // 데드락 오류인지 확인 boolean isDeadlock = e.getCause() != null && @@ -341,6 +347,7 @@ public class JobLauncherController { */ private boolean isJobRunning(String jobName) { try { + log.debug("Checking running executions for job: {}", jobName); Set runningExecutions = jobExplorer.findRunningJobExecutions(jobName); if (runningExecutions.isEmpty()) { return false; @@ -380,4 +387,18 @@ public class JobLauncherController { return false; } } + + private void logExceptionDetails(String context, String jobName, Exception e) { + Throwable root = e; + while (root.getCause() != null) { + root = root.getCause(); + } + if (root instanceof SQLException) { + SQLException sqlEx = (SQLException) root; + log.error("{} for job {}: SQLState={}, errorCode={}, message={}", + context, jobName, sqlEx.getSQLState(), sqlEx.getErrorCode(), sqlEx.getMessage(), e); + } else { + log.error("{} for job {}: {}", context, jobName, root.getMessage(), e); + } + } }