Mark builds as busy
This commit is contained in:
parent
8b12ac1f6d
commit
ca1fbdd058
|
@ -234,7 +234,7 @@ public:
|
||||||
|
|
||||||
void loadMachines();
|
void loadMachines();
|
||||||
|
|
||||||
void markActiveBuildStepsAsAborted(time_t stopTime);
|
void clearBusy(time_t stopTime);
|
||||||
|
|
||||||
int createBuildStep(pqxx::work & txn, time_t startTime, Build::ptr build, Step::ptr step,
|
int createBuildStep(pqxx::work & txn, time_t startTime, Build::ptr build, Step::ptr step,
|
||||||
BuildStepStatus status, const std::string & errorMsg = "", BuildID propagatedFrom = 0);
|
BuildStepStatus status, const std::string & errorMsg = "", BuildID propagatedFrom = 0);
|
||||||
|
@ -289,8 +289,8 @@ State::State()
|
||||||
State::~State()
|
State::~State()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
printMsg(lvlError, "clearing active build steps...");
|
printMsg(lvlError, "clearing active builds / build steps...");
|
||||||
markActiveBuildStepsAsAborted(time(0));
|
clearBusy(time(0));
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
ignoreException();
|
ignoreException();
|
||||||
}
|
}
|
||||||
|
@ -340,7 +340,7 @@ void State::loadMachines()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void State::markActiveBuildStepsAsAborted(time_t stopTime)
|
void State::clearBusy(time_t stopTime)
|
||||||
{
|
{
|
||||||
auto conn(dbPool.get());
|
auto conn(dbPool.get());
|
||||||
pqxx::work txn(*conn);
|
pqxx::work txn(*conn);
|
||||||
|
@ -348,6 +348,7 @@ void State::markActiveBuildStepsAsAborted(time_t stopTime)
|
||||||
("update BuildSteps set busy = 0, status = $1, stopTime = $2 where busy = 1")
|
("update BuildSteps set busy = 0, status = $1, stopTime = $2 where busy = 1")
|
||||||
((int) bssAborted)
|
((int) bssAborted)
|
||||||
(stopTime, stopTime != 0).exec();
|
(stopTime, stopTime != 0).exec();
|
||||||
|
txn.exec("update Builds set busy = 0 where finished = 0 and busy = 1");
|
||||||
txn.commit();
|
txn.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,7 +465,7 @@ void State::getQueuedBuilds(std::shared_ptr<StoreAPI> store)
|
||||||
printMsg(lvlInfo, format("aborting GC'ed build %1%") % build->id);
|
printMsg(lvlInfo, format("aborting GC'ed build %1%") % build->id);
|
||||||
pqxx::work txn(*conn);
|
pqxx::work txn(*conn);
|
||||||
txn.parameterized
|
txn.parameterized
|
||||||
("update Builds set finished = 1, buildStatus = $2, startTime = $3, stopTime = $3, errorMsg = $4 where id = $1")
|
("update Builds set finished = 1, busy = 0, buildStatus = $2, startTime = $3, stopTime = $3, errorMsg = $4 where id = $1")
|
||||||
(build->id)
|
(build->id)
|
||||||
((int) bsAborted)
|
((int) bsAborted)
|
||||||
(time(0))
|
(time(0))
|
||||||
|
@ -820,7 +821,7 @@ void State::doBuildStep(std::shared_ptr<StoreAPI> store, Step::ptr step,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a build step record indicating that we started
|
/* Create a build step record indicating that we started
|
||||||
building. */
|
building. Also, mark the selected build as busy. */
|
||||||
auto conn(dbPool.get());
|
auto conn(dbPool.get());
|
||||||
RemoteResult result;
|
RemoteResult result;
|
||||||
result.startTime = time(0);
|
result.startTime = time(0);
|
||||||
|
@ -828,6 +829,9 @@ void State::doBuildStep(std::shared_ptr<StoreAPI> store, Step::ptr step,
|
||||||
{
|
{
|
||||||
pqxx::work txn(*conn);
|
pqxx::work txn(*conn);
|
||||||
stepNr = createBuildStep(txn, result.startTime, build, step, bssBusy);
|
stepNr = createBuildStep(txn, result.startTime, build, step, bssBusy);
|
||||||
|
|
||||||
|
txn.parameterized("update Builds set busy = 1 where id = $1")(build->id).exec();
|
||||||
|
|
||||||
txn.commit();
|
txn.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -897,7 +901,7 @@ void State::doBuildStep(std::shared_ptr<StoreAPI> store, Step::ptr step,
|
||||||
for (auto build2 : dependents) {
|
for (auto build2 : dependents) {
|
||||||
printMsg(lvlError, format("marking build %1% as failed") % build2->id);
|
printMsg(lvlError, format("marking build %1% as failed") % build2->id);
|
||||||
txn.parameterized
|
txn.parameterized
|
||||||
("update Builds set finished = 1, isCachedBuild = 0, buildStatus = $2, startTime = $3, stopTime = $4 where id = $1")
|
("update Builds set finished = 1, busy = 0, isCachedBuild = 0, buildStatus = $2, startTime = $3, stopTime = $4 where id = $1")
|
||||||
(build2->id)
|
(build2->id)
|
||||||
((int) (build2->drvPath == step->drvPath ? bsFailed : bsDepFailed))
|
((int) (build2->drvPath == step->drvPath ? bsFailed : bsDepFailed))
|
||||||
(result.startTime)
|
(result.startTime)
|
||||||
|
@ -932,7 +936,7 @@ void State::markSucceededBuild(pqxx::work & txn, Build::ptr build,
|
||||||
printMsg(lvlError, format("marking build %1% as succeeded") % build->id);
|
printMsg(lvlError, format("marking build %1% as succeeded") % build->id);
|
||||||
|
|
||||||
txn.parameterized
|
txn.parameterized
|
||||||
("update Builds set finished = 1, buildStatus = $2, startTime = $3, stopTime = $4, size = $5, closureSize = $6, releaseName = $7, isCachedBuild = $8 where id = $1")
|
("update Builds set finished = 1, busy = 0, buildStatus = $2, startTime = $3, stopTime = $4, size = $5, closureSize = $6, releaseName = $7, isCachedBuild = $8 where id = $1")
|
||||||
(build->id)
|
(build->id)
|
||||||
((int) bsSuccess)
|
((int) bsSuccess)
|
||||||
(startTime)
|
(startTime)
|
||||||
|
@ -964,7 +968,7 @@ void State::markSucceededBuild(pqxx::work & txn, Build::ptr build,
|
||||||
|
|
||||||
void State::run()
|
void State::run()
|
||||||
{
|
{
|
||||||
markActiveBuildStepsAsAborted(0);
|
clearBusy(0);
|
||||||
|
|
||||||
loadMachines();
|
loadMachines();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue