Skip to content

Commit 8440afb

Browse files
committed
Revert "Adapt scheduler to work with dynamic derivations"
This reverts commit 5e3986f. This un-implements RFC 92 but fixes the critical bug #9052 which many people are hitting. This is a decent stop-gap until a minimal reproduction of that bug is found and a proper fix can be made. Mostly fixed #9052, but I would like to leave that issue open until we have a regression test, so I can then properly fix the bug (unbreaking RFC 92) later.
1 parent ea2f74c commit 8440afb

12 files changed

+55
-409
lines changed

src/libstore/build/create-derivation-and-realise-goal.cc

Lines changed: 0 additions & 157 deletions
This file was deleted.

src/libstore/build/create-derivation-and-realise-goal.hh

Lines changed: 0 additions & 96 deletions
This file was deleted.

src/libstore/build/derivation-goal.cc

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ DerivationGoal::DerivationGoal(const StorePath & drvPath,
7171
, wantedOutputs(wantedOutputs)
7272
, buildMode(buildMode)
7373
{
74-
state = &DerivationGoal::loadDerivation;
74+
state = &DerivationGoal::getDerivation;
7575
name = fmt(
7676
"building of '%s' from .drv file",
7777
DerivedPath::Built { makeConstantStorePathRef(drvPath), wantedOutputs }.to_string(worker.store));
@@ -164,6 +164,24 @@ void DerivationGoal::addWantedOutputs(const OutputsSpec & outputs)
164164
}
165165

166166

167+
void DerivationGoal::getDerivation()
168+
{
169+
trace("init");
170+
171+
/* The first thing to do is to make sure that the derivation
172+
exists. If it doesn't, it may be created through a
173+
substitute. */
174+
if (buildMode == bmNormal && worker.evalStore.isValidPath(drvPath)) {
175+
loadDerivation();
176+
return;
177+
}
178+
179+
addWaitee(upcast_goal(worker.makePathSubstitutionGoal(drvPath)));
180+
181+
state = &DerivationGoal::loadDerivation;
182+
}
183+
184+
167185
void DerivationGoal::loadDerivation()
168186
{
169187
trace("loading derivation");
@@ -1498,24 +1516,23 @@ void DerivationGoal::waiteeDone(GoalPtr waitee, ExitCode result)
14981516
if (!useDerivation) return;
14991517
auto & fullDrv = *dynamic_cast<Derivation *>(drv.get());
15001518

1501-
std::optional info = tryGetConcreteDrvGoal(waitee);
1502-
if (!info) return;
1503-
const auto & [dg, drvReq] = *info;
1519+
auto * dg = dynamic_cast<DerivationGoal *>(&*waitee);
1520+
if (!dg) return;
15041521

1505-
auto * nodeP = fullDrv.inputDrvs.findSlot(drvReq.get());
1522+
auto * nodeP = fullDrv.inputDrvs.findSlot(DerivedPath::Opaque { .path = dg->drvPath });
15061523
if (!nodeP) return;
15071524
auto & outputs = nodeP->value;
15081525

15091526
for (auto & outputName : outputs) {
1510-
auto buildResult = dg.get().getBuildResult(DerivedPath::Built {
1511-
.drvPath = makeConstantStorePathRef(dg.get().drvPath),
1527+
auto buildResult = dg->getBuildResult(DerivedPath::Built {
1528+
.drvPath = makeConstantStorePathRef(dg->drvPath),
15121529
.outputs = OutputsSpec::Names { outputName },
15131530
});
15141531
if (buildResult.success()) {
15151532
auto i = buildResult.builtOutputs.find(outputName);
15161533
if (i != buildResult.builtOutputs.end())
15171534
inputDrvOutputs.insert_or_assign(
1518-
{ dg.get().drvPath, outputName },
1535+
{ dg->drvPath, outputName },
15191536
i->second.outPath);
15201537
}
15211538
}

src/libstore/build/derivation-goal.hh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ struct InitialOutput {
5252

5353
/**
5454
* A goal for building some or all of the outputs of a derivation.
55-
*
56-
* The derivation must already be present, either in the store in a drv
57-
* or in memory. If the derivation itself needs to be gotten first, a
58-
* `CreateDerivationAndRealiseGoal` goal must be used instead.
5955
*/
6056
struct DerivationGoal : public Goal
6157
{
@@ -235,6 +231,7 @@ struct DerivationGoal : public Goal
235231
/**
236232
* The states.
237233
*/
234+
void getDerivation();
238235
void loadDerivation();
239236
void haveDerivation();
240237
void outputsSubstitutionTried();

src/libstore/build/entry-points.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "worker.hh"
22
#include "substitution-goal.hh"
3-
#include "create-derivation-and-realise-goal.hh"
43
#include "derivation-goal.hh"
54
#include "local-store.hh"
65

@@ -16,7 +15,7 @@ void Store::buildPaths(const std::vector<DerivedPath> & reqs, BuildMode buildMod
1615

1716
worker.run(goals);
1817

19-
StringSet failed;
18+
StorePathSet failed;
2019
std::optional<Error> ex;
2120
for (auto & i : goals) {
2221
if (i->ex) {
@@ -26,10 +25,10 @@ void Store::buildPaths(const std::vector<DerivedPath> & reqs, BuildMode buildMod
2625
ex = std::move(i->ex);
2726
}
2827
if (i->exitCode != Goal::ecSuccess) {
29-
if (auto i2 = dynamic_cast<CreateDerivationAndRealiseGoal *>(i.get()))
30-
failed.insert(i2->drvReq->to_string(*this));
28+
if (auto i2 = dynamic_cast<DerivationGoal *>(i.get()))
29+
failed.insert(i2->drvPath);
3130
else if (auto i2 = dynamic_cast<PathSubstitutionGoal *>(i.get()))
32-
failed.insert(printStorePath(i2->storePath));
31+
failed.insert(i2->storePath);
3332
}
3433
}
3534

@@ -38,7 +37,7 @@ void Store::buildPaths(const std::vector<DerivedPath> & reqs, BuildMode buildMod
3837
throw std::move(*ex);
3938
} else if (!failed.empty()) {
4039
if (ex) logError(ex->info());
41-
throw Error(worker.failingExitStatus(), "build of %s failed", concatStringsSep(", ", quoteStrings(failed)));
40+
throw Error(worker.failingExitStatus(), "build of %s failed", showPaths(failed));
4241
}
4342
}
4443

src/libstore/build/goal.hh

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,6 @@ enum struct JobCategory {
4949
* A substitution an arbitrary store object; it will use network resources.
5050
*/
5151
Substitution,
52-
/**
53-
* A goal that does no "real" work by itself, and just exists to depend on
54-
* other goals which *do* do real work. These goals therefore are not
55-
* limited.
56-
*
57-
* These goals cannot infinitely create themselves, so there is no risk of
58-
* a "fork bomb" type situation (which would be a problem even though the
59-
* goal do no real work) either.
60-
*/
61-
Administration,
6252
};
6353

6454
struct Goal : public std::enable_shared_from_this<Goal>

0 commit comments

Comments
 (0)