From 3cb2740721e8fde8f79979e7f4140d75ef578b12 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 18 Jan 2024 15:29:54 +0100 Subject: [PATCH 1/3] Show what goal is waiting for a build slot (cherry picked from commit ab786e22f16eed0d95123d5698eb71079c312584) --- src/libstore/build/worker.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstore/build/worker.cc b/src/libstore/build/worker.cc index 01914e2d6..75eb6e2f1 100644 --- a/src/libstore/build/worker.cc +++ b/src/libstore/build/worker.cc @@ -238,7 +238,7 @@ void Worker::childTerminated(Goal * goal, bool wakeSleepers) void Worker::waitForBuildSlot(GoalPtr goal) { - debug("wait for build slot"); + goal->trace("wait for build slot"); bool isSubstitutionGoal = goal->jobCategory() == JobCategory::Substitution; if ((!isSubstitutionGoal && getNrLocalBuilds() < settings.maxBuildJobs) || (isSubstitutionGoal && getNrSubstitutions() < settings.maxSubstitutionJobs)) From cc94ea5a174696f72f0c3f1bcf93ab9d24dfac7c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 18 Jan 2024 17:01:45 +0100 Subject: [PATCH 2/3] LocalStore::addToStore(): Ignore exceptions from parseDump() In the "discard" case (i.e. when the store path already exists locally), when we call parseDump() from a Finally and it throws an exception (e.g. if the download of the NAR fails), Nix crashes: terminate called after throwing an instance of 'nix::SubstituteGone' what(): error: file 'nar/06br3254rx4gz4cvjzxlv028jrx80zg5i4jr62vjmn416dqihgr7.nar.xz' does not exist in binary cache 'http://localhost' Aborted (core dumped) (cherry picked from commit a18d8d688a826ff535b3eeff289ef51db33a413b) --- src/libstore/local-store.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 2a3582ad8..8d6a8c909 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -1202,7 +1202,11 @@ void LocalStore::addToStore(const ValidPathInfo & info, Source & source, Finally cleanup = [&]() { if (!narRead) { NullParseSink sink; - parseDump(sink, source); + try { + parseDump(sink, source); + } catch (...) { + ignoreException(); + } } }; From fdf5313e7ea9ba6476734dc7b2c20b74855e95a4 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 18 Jan 2024 17:16:34 +0100 Subject: [PATCH 3/3] copyStorePath(): Bail out early if the store path already exists In rare cases (e.g. when using allowSubstitutes = false), it's possible that we simultaneously have a DerivationGoal *and* a SubstitutionGoal building the same path. So if a DerivationGoal already built the path while the SubstitutionGoal was waiting for a download slot, it saves us a superfluous download to exit early. (cherry picked from commit dca0a802405be9798e12ad8be2ec6d227d9a2fa2) --- src/libstore/store-api.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index fe1903ec6..43ce70cd2 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -982,6 +982,11 @@ void copyStorePath( RepairFlag repair, CheckSigsFlag checkSigs) { + /* Bail out early (before starting a download from srcStore) if + dstStore already has this path. */ + if (!repair && dstStore.isValidPath(storePath)) + return; + auto srcUri = srcStore.getUri(); auto dstUri = dstStore.getUri(); auto storePathS = srcStore.printStorePath(storePath);