Fix duplicate step_finished notification

This commit is contained in:
Eelco Dolstra 2019-08-12 15:50:43 +02:00
parent 976d88d675
commit 7c7cc8c059
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE

View file

@ -228,6 +228,11 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore,
time_t stepStopTime = time(0); time_t stepStopTime = time(0);
if (!result.stopTime) result.stopTime = stepStopTime; if (!result.stopTime) result.stopTime = stepStopTime;
/* For standard failures, we don't care about the error
message. */
if (result.stepStatus != bsAborted)
result.errorMsg = "";
/* Account the time we spent building this step by dividing it /* Account the time we spent building this step by dividing it
among the jobsets that depend on it. */ among the jobsets that depend on it. */
{ {
@ -240,6 +245,13 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore,
} }
} }
/* Finish the step in the database. */
if (stepNr) {
pqxx::work txn(*conn);
finishBuildStep(txn, result, buildId, stepNr, machine->sshName);
txn.commit();
}
/* The step had a hopefully temporary failure (e.g. network /* The step had a hopefully temporary failure (e.g. network
issue). Retry a number of times. */ issue). Retry a number of times. */
if (result.canRetry) { if (result.canRetry) {
@ -253,11 +265,6 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore,
} }
if (retry) { if (retry) {
auto mc = startDbUpdate(); auto mc = startDbUpdate();
{
pqxx::work txn(*conn);
finishBuildStep(txn, result, buildId, stepNr, machine->sshName);
txn.commit();
}
stepFinished = true; stepFinished = true;
if (quit) exit(1); if (quit) exit(1);
return sRetry; return sRetry;
@ -312,8 +319,6 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore,
pqxx::work txn(*conn); pqxx::work txn(*conn);
finishBuildStep(txn, result, buildId, stepNr, machine->sshName);
for (auto & b : direct) { for (auto & b : direct) {
printMsg(lvlInfo, format("marking build %1% as succeeded") % b->id); printMsg(lvlInfo, format("marking build %1% as succeeded") % b->id);
markSucceededBuild(txn, b, res, buildId != b->id || result.isCached, markSucceededBuild(txn, b, res, buildId != b->id || result.isCached,
@ -370,11 +375,6 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore,
} else { } else {
/* For standard failures, we don't care about the error
message. */
if (result.stepStatus != bsAborted)
result.errorMsg = "";
/* Register failure in the database for all Build objects that /* Register failure in the database for all Build objects that
directly or indirectly depend on this step. */ directly or indirectly depend on this step. */
@ -420,11 +420,6 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore,
result.stepStatus, result.errorMsg, buildId == build2->id ? 0 : buildId); result.stepStatus, result.errorMsg, buildId == build2->id ? 0 : buildId);
} }
if (result.stepStatus != bsCachedFailure && !stepFinished) {
assert(stepNr);
finishBuildStep(txn, result, buildId, stepNr, machine->sshName);
}
/* Mark all builds that depend on this derivation as failed. */ /* Mark all builds that depend on this derivation as failed. */
for (auto & build2 : indirect) { for (auto & build2 : indirect) {
if (build2->finishedInDB) continue; if (build2->finishedInDB) continue;