forked from lix-project/hydra
hydra-update-gc-roots: Get Builds and BuildOutputs in the same query
This greatly reduces the number of roundtrips to the database.
This commit is contained in:
parent
9989a90e99
commit
672bbb1c67
|
@ -22,7 +22,10 @@ sub addRoot {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
my @columns = ( "id", "project", "jobset", "job", "system", "finished", "drvpath", "timestamp", "buildstatus" );
|
my @columns =
|
||||||
|
( "id", "project", "jobset", "job", "system", "finished", "drvpath", "timestamp", "buildstatus"
|
||||||
|
, { "outpaths" => \ "(select string_agg(path, ' ') from BuildOutputs where build = me.id)" }
|
||||||
|
);
|
||||||
|
|
||||||
my %seenBuilds;
|
my %seenBuilds;
|
||||||
|
|
||||||
|
@ -35,11 +38,11 @@ sub keepBuild {
|
||||||
$build->system, "; ",
|
$build->system, "; ",
|
||||||
strftime("%Y-%m-%d %H:%M:%S", localtime($build->timestamp)), ")\n";
|
strftime("%Y-%m-%d %H:%M:%S", localtime($build->timestamp)), ")\n";
|
||||||
if ($build->finished && ($build->buildstatus == 0 || $build->buildstatus == 6)) {
|
if ($build->finished && ($build->buildstatus == 0 || $build->buildstatus == 6)) {
|
||||||
foreach my $out ($build->buildoutputs->all) {
|
foreach my $path (split / /, $build->get_column('outpaths')) {
|
||||||
if (isValidPath($out->path)) {
|
if (isValidPath($path)) {
|
||||||
addRoot $out->path;
|
addRoot $path;
|
||||||
} else {
|
} else {
|
||||||
print STDERR " warning: output ", $out->path, " has disappeared\n" if $build->finished;
|
print STDERR " warning: output ", $path, " has disappeared\n" if $build->finished;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue