fix(worker): guard against same task in queue and override slot

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
mika kuns
2026-04-17 14:23:08 +02:00
parent f10ad69863
commit 11a4376da5
2 changed files with 151 additions and 1 deletions

View File

@@ -68,6 +68,8 @@ public sealed class QueueService : BackgroundService
lock (_lock)
{
if (_queueSlot?.TaskId == taskId)
throw new InvalidOperationException("task is already running in queue slot");
if (_overrideSlot is not null)
throw new InvalidOperationException("override slot busy");
@@ -92,10 +94,12 @@ public sealed class QueueService : BackgroundService
?? throw new KeyNotFoundException($"Task '{taskId}' not found.");
if (task.Status == Data.Models.TaskStatus.Running)
throw new InvalidOperationException("Task is currently running.");
throw new InvalidOperationException("task is already running");
lock (_lock)
{
if (_queueSlot?.TaskId == taskId)
throw new InvalidOperationException("task is already running in queue slot");
if (_overrideSlot is not null)
throw new InvalidOperationException("override slot busy");