From 3f68076577e7579549d631ece1aacc4627e361eb Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 10 Sep 2013 11:01:29 +0000 Subject: [PATCH] hydra-build: Don't send a giant query to the database MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We had Postgres barfing with this error: DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::Pg::st execute failed: ERROR: stack depth limit exceeded because the ‘drvpath => [ @dependentDrvs ]’ in failDependents can cause a query of unbounded size. (In this specific case there was a failure of Bison, which has > 10000 dependent derivations.) So now we just get all scheduled builds from the DB. --- release.nix | 1 + src/script/hydra-build | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/release.nix b/release.nix index 868ba424..0431c500 100644 --- a/release.nix +++ b/release.nix @@ -92,6 +92,7 @@ in rec { PadWalker CatalystDevel Readonly + SetScalar SQLSplitStatement Starman SysHostnameLong diff --git a/src/script/hydra-build b/src/script/hydra-build index 39f75aba..557090cc 100755 --- a/src/script/hydra-build +++ b/src/script/hydra-build @@ -11,6 +11,7 @@ use Hydra::Helper::Nix; use Hydra::Helper::PluginHooks; use Hydra::Model::DB; use Hydra::Helper::AddBuilds; +use Set::Scalar; STDOUT->autoflush(); @@ -41,16 +42,18 @@ sub failDependents { my ($drvPath, $status, $errorMsg, $dependents) = @_; # Get the referrer closure of $drvPath. - my @dependentDrvs = computeFSClosure(1, 0, $drvPath); + my $dependentDrvs = Set::Scalar->new(computeFSClosure(1, 0, $drvPath)); my $time = time(); txn_do($db, sub { my @dependentBuilds = $db->resultset('Builds')->search( - { drvpath => [ @dependentDrvs ], finished => 0, busy => 0 }); + { finished => 0, busy => 0 }, + { columns => ["id", "project", "jobset", "job", "drvpath"] }); for my $d (@dependentBuilds) { + next unless $dependentDrvs->has($d->drvpath); print STDERR "failing dependent build ", $d->id, " of ", $d->project->name, ":", $d->jobset->name, ":", $d->job->name, "\n"; $d->update( { finished => 1