Skip to content

Commit

Permalink
Change to use the waiting tasks in the filter for task metrics.
Browse files Browse the repository at this point in the history
Closes #5941

After some discussion we decided to use the task status in the filter
that search for unblocked tasks in the queue. This can avoid a situation
where tasks have the `unblocked_at` field filled yet they are not
waiting in the queue anymore.

(cherry picked from commit b78977c)
  • Loading branch information
decko authored and patchback[bot] committed Nov 13, 2024
1 parent c144f7b commit 435b044
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES/5941.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed incorrect count of waiting tasks in the queue for the `tasks_unblocked_queue` and `tasks_longest_unblocked_time` metrics.
2 changes: 1 addition & 1 deletion pulpcore/tasking/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,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(
Expand Down

0 comments on commit 435b044

Please sign in to comment.