From 19aee99fb214277a9e3c6233598dca50362a9fac Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 7 Feb 2024 14:32:48 -0800 Subject: [PATCH] add debug log for WorkerService remainder/claim freeze --- .../src/main/java/jpl/cws/core/db/SchedulerDbService.java | 7 +++++++ .../src/main/java/jpl/cws/engine/WorkerService.java | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/cws-core/src/main/java/jpl/cws/core/db/SchedulerDbService.java b/cws-core/src/main/java/jpl/cws/core/db/SchedulerDbService.java index 83d015bd..7dd9c353 100644 --- a/cws-core/src/main/java/jpl/cws/core/db/SchedulerDbService.java +++ b/cws-core/src/main/java/jpl/cws/core/db/SchedulerDbService.java @@ -398,6 +398,13 @@ public int getCountForClaimedProcInstPerKey(String procDefKey, List clai return jdbcTemplate.queryForObject(query, Integer.class); } + public List> getProcDefKeyLatestCompleteInst(String procDefKey) { + return jdbcTemplate.queryForList( + "SELECT proc_inst_id, start_time, end_time FROM cws_proc_inst_status WHERE proc_def_key=? AND status='complete' ORDER BY start_time DESC LIMIT 1", + new Object[]{procDefKey} + ); + } + public String getProcDefKeyFromUuid(String uuid) { String query = "SELECT proc_def_key FROM cws_sched_worker_proc_inst " + "WHERE uuid='" + uuid + "'"; diff --git a/cws-engine-service/src/main/java/jpl/cws/engine/WorkerService.java b/cws-engine-service/src/main/java/jpl/cws/engine/WorkerService.java index 17e58997..94b97a08 100644 --- a/cws-engine-service/src/main/java/jpl/cws/engine/WorkerService.java +++ b/cws-engine-service/src/main/java/jpl/cws/engine/WorkerService.java @@ -756,6 +756,13 @@ public List> claimWithCounter(String limitToProcDefKey) { "(remainders = " + remainders + ", procMaxNumbers = " + workerMaxProcInstances.entrySet() + ", currentCounts = " + currentCounts + ")"); + + for (Entry entry : remainders.entrySet()) { + List> lastCompleteProcInst = schedulerDbService.getProcDefKeyLatestCompleteInst(entry.getKey().toString()); + if (lastCompleteProcInst.size() > 0) { + log.debug("Last completed process instance for procDefKey '" + entry.getKey().toString() + "': " + lastCompleteProcInst); + } + } }