20183: Update container priority in creation order. 20183-update-priority-thread
authorTom Clegg <tom@curii.com>
Thu, 9 Mar 2023 21:50:03 +0000 (16:50 -0500)
committerTom Clegg <tom@curii.com>
Thu, 9 Mar 2023 21:50:03 +0000 (16:50 -0500)
When multiple containers in a tree need updates, this is effectively
top-down order, which is more efficient. The topmost update will
update the whole tree anyway, so updating subtrees first would be a
waste.

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

lib/controller/localdb/container.go

index ad1da6e13010f4bbc9555e410c258ee9ae0737ff..52a3974aa1c37806bb77e5ba4907a045c493f461 100644 (file)
@@ -107,6 +107,7 @@ func (conn *Conn) containerPriorityUpdate(ctx context.Context, log logrus.FieldL
                        WHERE containers.state IN ('Queued', 'Locked', 'Running')
                         AND containers.priority = 0
                         AND (parent.uuid IS NULL OR parent.priority > 0)
+                       ORDER BY containers.created_at
                        LIMIT 1`).Scan(&uuid)
                if err == sql.ErrNoRows {
                        break