1
0
Fork 0
mirror of https://github.com/NixOS/hydra.git synced 2024-10-18 17:02:28 -04:00

Make restartBuilds faster

This commit is contained in:
Eelco Dolstra 2014-07-18 00:02:59 +02:00
parent 365de86ead
commit 6b88be040e

View file

@ -572,38 +572,37 @@ sub cancelBuilds($$) {
sub restartBuilds($$) { sub restartBuilds($$) {
my ($db, $builds) = @_; my ($db, $builds) = @_;
my $n = 0; my @buildIds;
txn_do($db, sub { txn_do($db, sub {
my @paths; my @paths;
$builds = $builds->search({ finished => 1 }); $builds = $builds->search({ finished => 1 });
foreach my $build ($builds->all) { foreach my $build ($builds->all) {
next if !isValidPath($build->drvpath); next if !isValidPath($build->drvpath);
push @paths, $build->drvpath; push @paths, $build->drvpath;
push @paths, $_->drvpath foreach $build->buildsteps; push @buildIds, $build->id;
registerRoot $build->drvpath; registerRoot $build->drvpath;
$build->update(
{ finished => 0
, busy => 0
, locker => ""
, iscachedbuild => 0
});
$n++;
# Reset the stats for the evals to which this build belongs.
# !!! Should do this in a trigger.
$build->jobsetevals->update({nrsucceeded => undef});
} }
$db->resultset('Builds')->search({ id => \@buildIds })->update(
{ finished => 0
, busy => 0
, locker => ""
, iscachedbuild => 0
});
# Reset the stats for the evals to which the builds belongs.
# !!! Should do this in a trigger.
$db->resultset('JobsetEvals')->search({ build => \@buildIds }, { join => 'buildIds' })->update({ nrsucceeded => undef });
# Clear Nix's negative failure cache. # Clear Nix's negative failure cache.
# FIXME: Add this to the API. # FIXME: Add this to the API.
system("nix-store", "--clear-failed-paths", @paths); system("nix-store", "--clear-failed-paths", @paths);
}); });
return $n; return scalar(@buildIds);
} }