hydra-build: Don't send a giant query to the database

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.
This commit is contained in:
Eelco Dolstra 2013-09-10 11:01:29 +00:00
parent 35aad40692
commit 3f68076577
2 changed files with 6 additions and 2 deletions

View file

@ -92,6 +92,7 @@ in rec {
PadWalker
CatalystDevel
Readonly
SetScalar
SQLSplitStatement
Starman
SysHostnameLong

View file

@ -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