From f47749a62d9495279e9e43a868ea63a637019ec9 Mon Sep 17 00:00:00 2001 From: "Ricardo M. Correia" Date: Tue, 10 Nov 2020 04:05:59 +0100 Subject: [PATCH] Fix persistent hash mismatch errors when importing This would start happening if the network connection between the Hydra server and the remote build server breaks after sucessfully importing at least one output of a derivation, but before having finished importing all outputs. Fixes #816. --- src/hydra-queue-runner/build-remote.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/hydra-queue-runner/build-remote.cc b/src/hydra-queue-runner/build-remote.cc index 2f9df16f..4565b82e 100644 --- a/src/hydra-queue-runner/build-remote.cc +++ b/src/hydra-queue-runner/build-remote.cc @@ -481,14 +481,22 @@ void State::buildRemote(ref destStore, for (auto & path : pathsSorted) { auto & info = infos.find(path)->second; - to << cmdDumpStorePath << localStore->printStorePath(path); - to.flush(); /* Receive the NAR from the remote and add it to the destination store. Meanwhile, extract all the info from the NAR that getBuildOutput() needs. */ auto source2 = sinkToSource([&](Sink & sink) { + /* Note: we should only send the command to dump the store + path to the remote if the NAR is actually going to get read + by the destination store, which won't happen if this path + is already valid on the destination store. Since this + lambda function only gets executed if someone tries to read + from source2, we will send the command from here rather + than outside the lambda. */ + to << cmdDumpStorePath << localStore->printStorePath(path); + to.flush(); + TeeSource tee(from, sink); extractNarData(tee, localStore->printStorePath(path), narMembers); });