We now keep all unfinished evaluations of a jobset, in addition to the <keepnr> most recent finished evaluations.
The main motivation is to ensure that mirror-{nixos,nixpkgs} work properly: if building an evaluation takes too long, some of its builds may already have been garbage-collected by the time the others finish.
ACFFJUAN5R2AFJVVJ5OBX6BQHT3M4SHO7QXILF5LURVIFPDORLIQC
MUBBWJPAEREQVNWR7BYMGWLFKHY2LZBNLZKHT2WT6PVNSM2PFX2QC
SZPBGW2NVHOOW4E3VIB2B35V7YRF67DFVVGUK573LVD574IHSA6AC
KJQWSRCCQEKF64L4NYYZ7VKAF2YEPYXXTRW6BI464P6Q6KU34TQAC
WZ3AEJ67LOG5L335AAC2BDLIJPIU4VSCGBMATBHDZC26ECRS5A6AC
ONAQU4BRGYO6MGPGIQIK5KF4JE4TBJMFFBU5XBKFTYQ5RPW7FOYQC
6KJXJB7NZ5XJ3WGUWKFNT6LMBNYJN3IPHZ7B7H654D5B6LPOL5QAC
I3X25POIIRIY47QTN2PA3WMDVROM6TLFJAV3Q5W6AU526TFPNHKAC
PMNWRTGJ4GVSMSSAWSUD57B26PCRAHMZIQ5SIWJIK7A74ENKEQLAC
4X6NS66QDWR4S4ZZFKN2QOJQII5ZYIMTDYRHK25N6NJSROVLHJ6QC
A63IHCMXH3F4V56HDXJLJVVHKXRSJCJMT2PWXXI2IW3J734J6SGQC
NEWDDAOFCDLYBXQCZNQ2GDH7HPAHVN3YRDL52ZYEMVA4YH6LBDXAC
2T42QGZDK23C5V4ZHO4R7EBJESIQ62GKWDBWVX7OBEE3YVBUNUFAC
my @evals;
# Get the unfinished evals.
push @evals, $_->get_column("eval") foreach $jobset->builds->search(
{ finished => 0 },
{ join => "jobsetevalmembers", select => "jobsetevalmembers.eval", as => "eval", distinct => 1 });
# Get the N most recent finished evals.
if ($keepnr) {
push @evals, $_->get_column("id") foreach $jobset->jobsetevals->search(
{ hasNewBuilds => 1 },
{ where => \ "not exists (select 1 from builds b join jobsetevalmembers m on b.id = m.build where m.eval = me.id and b.finished = 0)"
, order_by => "id desc", rows => $keepnr });
}
, id => { -in =>
\ [ "select build from JobsetEvalMembers where eval in (select id from JobsetEvals where project = ? and jobset = ? and hasNewBuilds = 1 order by id desc limit ?)",
[ '', $project->name ], [ '', $jobset->name ], [ '', $keepnr ] ] }
, id => { -in => $db->resultset('JobsetEvalMembers')->search({ eval => { -in => [@evals] } }, { select => "build" })->as_query }
# For scheduled builds, we register the derivation as a GC root.
print STDERR "*** looking for scheduled builds\n";
keepBuild $_ foreach $db->resultset('Builds')->search({ finished => 0 }, { columns => [ @columns ] });