diff --git a/CHANGES/5941.bugfix b/CHANGES/5941.bugfix new file mode 100644 index 0000000000..59b67b456e --- /dev/null +++ b/CHANGES/5941.bugfix @@ -0,0 +1 @@ +Fixed incorrect count of waiting tasks in the queue for the `tasks_unblocked_queue` and `tasks_longest_unblocked_time` metrics. diff --git a/pulpcore/tasking/worker.py b/pulpcore/tasking/worker.py index 5598395b3b..8ad8520e0b 100644 --- a/pulpcore/tasking/worker.py +++ b/pulpcore/tasking/worker.py @@ -467,7 +467,7 @@ def record_unblocked_waiting_tasks_metric(self): ): # For performance reasons we aggregate these statistics on a single database call. unblocked_tasks_stats = ( - Task.objects.filter(unblocked_at__isnull=False, started_at__isnull=True) + Task.objects.filter(unblocked_at__isnull=False, state=TASK_STATES.WAITING) .annotate(unblocked_for=Value(timezone.now()) - F("unblocked_at")) .aggregate( longest_unblocked_waiting_time=Max(