Skip to content
This repository was archived by the owner on Apr 24, 2023. It is now read-only.

Commit f099b31

Browse files
author
Scott Crosby
committed
Make the user cache work for job entities in the queue.
task-ent->user uses :db/id as a cache key. However, synthetic tasks entities for pending jobs don't have that and aren't cached. This makes that cache essentially noop for pending jobs; they always miss. Fix this by borrowing the :db/id of the source job.
1 parent 0724038 commit f099b31

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

scheduler/src/cook/tools.clj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,12 @@
561561
(defn create-task-ent
562562
"Takes a pending job entity and returns a synthetic running task entity for that job"
563563
[pending-job-ent & {:keys [hostname slave-id] :or {hostname nil slave-id nil}}]
564-
(merge {:job/_instance pending-job-ent
564+
; task-ent->user uses :db/id as a cache key. However, synthetic tasks
565+
; entities for pending jobs don't have that and aren't cached. This makes
566+
; that cache essentially noop for pending jobs; they always miss.
567+
; Fix this by borrowing the :db/id of the source job.
568+
(merge {:db/id (- (:db/id pending-job-ent))
569+
:job/_instance pending-job-ent
565570
:instance/status :instance.status/running}
566571
(when hostname {:instance/hostname hostname})
567572
(when slave-id {:instance/slave-id slave-id})))

0 commit comments

Comments
 (0)