Prevent multiple builds with the same (job, outPath) tuple from being added

This happened in a pathological case in Nixpkgs: the "grub" job is
evaluated for i686-linux and x86_64-linux, but in the latter case it
returns the same derivation as in the former case.  So only one build
should be added.
This commit is contained in:
Eelco Dolstra 2012-04-02 15:56:29 +00:00
parent 9d4cb29e08
commit 2f9153c640
3 changed files with 14 additions and 3 deletions

View file

@ -532,7 +532,7 @@ sub clone_submit : Chained('build') PathPart('clone/submit') Args(0) {
my %currentBuilds;
my $newBuild = checkBuild(
$c->model('DB'), $build->project, $build->jobset,
$inputInfo, $nixExprInput, $job, \%currentBuilds, undef);
$inputInfo, $nixExprInput, $job, \%currentBuilds, undef, {});
error($c, "This build has already been performed.") unless $newBuild;

View file

@ -803,7 +803,7 @@ sub getPrevJobsetEval {
# Check whether to add the build described by $buildInfo.
sub checkBuild {
my ($db, $project, $jobset, $inputInfo, $nixExprInput, $buildInfo, $buildIds, $prevEval) = @_;
my ($db, $project, $jobset, $inputInfo, $nixExprInput, $buildInfo, $buildIds, $prevEval, $jobOutPathMap) = @_;
my $jobName = $buildInfo->{jobName};
my $drvPath = $buildInfo->{drvPath};
@ -844,6 +844,14 @@ sub checkBuild {
return;
}
}
# Prevent multiple builds with the same (job, outPath) from
# being added.
my $prev = $$jobOutPathMap{$job->name . "\t" . $outPath};
if (defined $prev) {
print STDERR " already scheduled as build ", $prev, "\n";
return;
}
my $time = time();
@ -886,6 +894,7 @@ sub checkBuild {
});
$buildIds->{$build->id} = 1;
$$jobOutPathMap{$job->name . "\t" . $outPath} = $build->id;
if ($build->iscachedbuild) {
print STDERR " marked as cached build ", $build->id, "\n";

View file

@ -124,6 +124,8 @@ sub checkJobset {
my ($jobs, $nixExprInput) = evalJobs($inputInfo, $jobset->nixexprinput, $jobset->nixexprpath);
my $evalStop = time;
my $jobOutPathMap = {};
txn_do($db, sub {
my $prevEval = getPrevJobsetEval($db, $jobset, 1);
@ -138,7 +140,7 @@ sub checkJobset {
foreach my $job (permute @{$jobs->{job}}) {
next if $job->{jobName} eq "";
print STDERR " considering job " . $project->name, ":", $jobset->name, ":", $job->{jobName} . "\n";
checkBuild($db, $project, $jobset, $inputInfo, $nixExprInput, $job, \%buildIds, $prevEval);
checkBuild($db, $project, $jobset, $inputInfo, $nixExprInput, $job, \%buildIds, $prevEval, $jobOutPathMap);
}
# Update the last checked times and error messages for each