Restart jobset evals efficiently

Fixes

  DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::Pg::st execute failed: ERROR: stack depth limit exceeded
  HINT: Increase the configuration parameter "max_stack_depth" (currently 2048kB), after ensuring the platform's stack depth limit is adequate. [for Statement "UPDATE Builds SET busy = ?, finished = ?, iscachedbuild = ?, locker = ? WHERE ( ( id = ? OR id = ? OR ...
This commit is contained in:
Eelco Dolstra 2015-10-27 13:43:19 +01:00
parent 53c80d9526
commit 9fb91460e3

View file

@ -442,22 +442,18 @@ sub cancelBuilds($$) {
sub restartBuilds($$) { sub restartBuilds($$) {
my ($db, $builds) = @_; my ($db, $builds) = @_;
my @buildIds;
$builds = $builds->search({ finished => 1 });
foreach my $build ($builds->search({}, { columns => ["drvpath"] })) {
next if !isValidPath($build->drvpath);
registerRoot $build->drvpath;
}
my $nrRestarted = 0;
txn_do($db, sub { txn_do($db, sub {
my %paths; $nrRestarted = $builds->update(
$builds = $builds->search({ finished => 1 });
foreach my $build ($builds->all) {
next if !isValidPath($build->drvpath);
$paths{$_->path} = 1 foreach $build->buildoutputs->all;
$paths{$_->path} = 1 foreach $build->buildstepoutputs->all;
push @buildIds, $build->id;
registerRoot $build->drvpath;
}
$db->resultset('Builds')->search({ id => \@buildIds })->update(
{ finished => 0 { finished => 0
, busy => 0 , busy => 0
, locker => "" , locker => ""
@ -466,14 +462,22 @@ sub restartBuilds($$) {
# Reset the stats for the evals to which the builds belongs. # Reset the stats for the evals to which the builds belongs.
# !!! Should do this in a trigger. # !!! Should do this in a trigger.
$db->resultset('JobsetEvals')->search({ build => \@buildIds }, { join => 'buildIds' })->update({ nrsucceeded => undef }); $db->resultset('JobsetEvals')->search(
{ id => { -in => $builds->search({}, { join => { 'jobsetevalmembers' => 'eval' }, select => "jobsetevalmembers.eval", as => "eval", distinct => 1 })->as_query }
})->update({ nrsucceeded => undef });
# Clear the failed paths cache. # Clear the failed paths cache.
# FIXME: Add this to the API. # FIXME: Add this to the API.
$db->resultset('FailedPaths')->search({ path => [ keys %paths ]})->delete; my $cleared = $db->resultset('FailedPaths')->search(
{ path => { -in => $builds->search({}, { join => "buildoutputs", select => "buildoutputs.path", as => "path", distinct => 1 })->as_query }
})->delete;
$cleared += $db->resultset('FailedPaths')->search(
{ path => { -in => $builds->search({}, { join => "buildstepoutputs", select => "buildstepoutputs.path", as => "path", distinct => 1 })->as_query }
})->delete;
print STDERR "cleared $cleared failed paths\n";
}); });
return scalar(@buildIds); return $nrRestarted;
} }