From a713a006dd6c442457047ba5819f6c3318cf920f Mon Sep 17 00:00:00 2001 From: Alessandro Benetton <aleben98@gmail.com> Date: Sat, 25 Jan 2025 12:10:32 +0100 Subject: [PATCH] [postgres-Server-V2] fix: Updated Job logic to spawn a job only if a job with the same id is not already in the RunningJobs list --- API/Tranga.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/API/Tranga.cs b/API/Tranga.cs index e6d89a3..a9d9647 100644 --- a/API/Tranga.cs +++ b/API/Tranga.cs @@ -79,6 +79,9 @@ public static class Tranga List<Job> runJobs = context.Jobs.Where(j => j.state <= JobState.Running).ToList().Where(j => j.NextExecution < DateTime.UtcNow).ToList(); foreach (Job job in runJobs) { + // If the job is already running, skip it + if (RunningJobs.Values.Any(j => j.JobId == job.JobId)) continue; + Thread t = new (() => { IEnumerable<Job> newJobs = job.Run(context);