From a95d740c598476c631586d165e1924e3f1c6effa Mon Sep 17 00:00:00 2001 From: da3dsoul Date: Sun, 7 Jan 2024 23:39:49 -0500 Subject: [PATCH] Fix ThreadPooledJobStore, which also fixes the queue --- Shoko.Server/Scheduling/ThreadPooledJobStore.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Shoko.Server/Scheduling/ThreadPooledJobStore.cs b/Shoko.Server/Scheduling/ThreadPooledJobStore.cs index f33e8869c..769b17c24 100644 --- a/Shoko.Server/Scheduling/ThreadPooledJobStore.cs +++ b/Shoko.Server/Scheduling/ThreadPooledJobStore.cs @@ -102,19 +102,19 @@ protected override async Task> AcquireNext if (ObjectUtils.IsAttributePresent(jobType, typeof(DisallowConcurrentExecutionAttribute))) { - if (acquiredJobKeysForNoConcurrentExec.ContainsKey(jobType)) continue; - acquiredJobKeysForNoConcurrentExec[jobType] += 1; + if (acquiredJobKeysForNoConcurrentExec.TryGetValue(jobType, out var number) && number >= 1) continue; + acquiredJobKeysForNoConcurrentExec[jobType] = number + 1; } else if (jobType.GetCustomAttributes().FirstOrDefault(a => a is LimitConcurrencyAttribute) is LimitConcurrencyAttribute attribute) { if (!_typeConcurrencyCache.TryGetValue(jobType, out var maxConcurrentJobs)) maxConcurrentJobs = attribute.MaxConcurrentJobs; if (acquiredJobKeysForNoConcurrentExec.TryGetValue(jobType, out var number) && number >= maxConcurrentJobs) continue; - acquiredJobKeysForNoConcurrentExec[jobType] += 1; + acquiredJobKeysForNoConcurrentExec[jobType] = number + 1; } else if (_typeConcurrencyCache.TryGetValue(jobType, out var maxJobs) && maxJobs > 0) { if (acquiredJobKeysForNoConcurrentExec.TryGetValue(jobType, out var number) && number >= maxJobs) continue; - acquiredJobKeysForNoConcurrentExec[jobType] += 1; + acquiredJobKeysForNoConcurrentExec[jobType] = number + 1; } var nextFireTimeUtc = nextTrigger.GetNextFireTimeUtc();