From 65728695967d18dc1ce7f7a0e2b67db5a638981c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 14 Jan 2014 18:14:10 +0100 Subject: [PATCH] clear-queue-non-current: Work around PostgreSQL query optimizer stupidity --- src/lib/Hydra/Controller/Admin.pm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/Hydra/Controller/Admin.pm b/src/lib/Hydra/Controller/Admin.pm index a73762dc..df14212f 100644 --- a/src/lib/Hydra/Controller/Admin.pm +++ b/src/lib/Hydra/Controller/Admin.pm @@ -35,8 +35,7 @@ sub machines : Chained('admin') PathPart('machines') Args(0) { sub clear_queue_non_current : Chained('admin') PathPart('clear-queue-non-current') Args(0) { my ($self, $c) = @_; my $builds = $c->model('DB::Builds')->search( - { finished => 0, busy => 0 - , id => { -not_in => \ "select build from JobsetEvalMembers where eval in (select max(id) from JobsetEvals where hasNewBuilds = 1 group by project, jobset)" } + { id => { -in => \ "select id from Builds where id in ((select id from Builds where finished = 0 and busy = 0) except (select build from JobsetEvalMembers where eval in (select max(id) from JobsetEvals where hasNewBuilds = 1 group by project, jobset)))" } }); my $n = cancelBuilds($c->model('DB')->schema, $builds); $c->flash->{successMsg} = "$n builds have been cancelled.";