From bebda2547bd35cafb828e3e7a043b1c1847fa7f6 Mon Sep 17 00:00:00 2001 From: Alessandro Degano Date: Wed, 27 Nov 2019 12:59:47 +0100 Subject: [PATCH] Fix queue ordering. --- atc/db/task_queue.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/atc/db/task_queue.go b/atc/db/task_queue.go index 24db0bc98c0..2f25e2eb8ae 100644 --- a/atc/db/task_queue.go +++ b/atc/db/task_queue.go @@ -91,10 +91,9 @@ func (queue *taskQueue) Position(id string) (position int, err error) { return 0, err } } - tasks_positions := psql.Select("row_number() over (), id"). + tasks_positions := psql.Select("row_number() over (order by insert_time), id"). From("tasks_queue"). - Where(sq.Eq{"platform": platform, "team_id": teamId, "worker_tag": workerTag}). - OrderBy("insert_time") + Where(sq.Eq{"platform": platform, "team_id": teamId, "worker_tag": workerTag}) err = psql.Select("row_number"). FromSelect(tasks_positions, "subq"). Where(sq.Eq{"id": id}).