Fix race in finishing builds that have been cancelled
This commit is contained in:
parent
90c462a222
commit
f1fbf8c605
|
@ -211,6 +211,8 @@ void State::markSucceededBuild(pqxx::work & txn, Build::ptr build,
|
||||||
|
|
||||||
if (build->finishedInDB) return;
|
if (build->finishedInDB) return;
|
||||||
|
|
||||||
|
if (txn.parameterized("select 1 from Builds where id = $1 and finished = 0")(build->id).exec().empty()) return;
|
||||||
|
|
||||||
txn.parameterized
|
txn.parameterized
|
||||||
("update Builds set finished = 1, busy = 0, buildStatus = $2, startTime = $3, stopTime = $4, size = $5, closureSize = $6, releaseName = $7, isCachedBuild = $8 where id = $1 and finished = 0")
|
("update Builds set finished = 1, busy = 0, buildStatus = $2, startTime = $3, stopTime = $4, size = $5, closureSize = $6, releaseName = $7, isCachedBuild = $8 where id = $1 and finished = 0")
|
||||||
(build->id)
|
(build->id)
|
||||||
|
@ -222,6 +224,8 @@ void State::markSucceededBuild(pqxx::work & txn, Build::ptr build,
|
||||||
(res.releaseName, res.releaseName != "")
|
(res.releaseName, res.releaseName != "")
|
||||||
(isCachedBuild ? 1 : 0).exec();
|
(isCachedBuild ? 1 : 0).exec();
|
||||||
|
|
||||||
|
txn.parameterized("delete from BuildProducts where build = $1")(build->id).exec();
|
||||||
|
|
||||||
unsigned int productNr = 1;
|
unsigned int productNr = 1;
|
||||||
for (auto & product : res.products) {
|
for (auto & product : res.products) {
|
||||||
txn.parameterized
|
txn.parameterized
|
||||||
|
@ -238,6 +242,8 @@ void State::markSucceededBuild(pqxx::work & txn, Build::ptr build,
|
||||||
(product.defaultPath).exec();
|
(product.defaultPath).exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
txn.parameterized("delete from BuildMetrics where build = $1")(build->id).exec();
|
||||||
|
|
||||||
for (auto & metric : res.metrics) {
|
for (auto & metric : res.metrics) {
|
||||||
txn.parameterized
|
txn.parameterized
|
||||||
("insert into BuildMetrics (build, name, unit, value, project, jobset, job, timestamp) values ($1, $2, $3, $4, $5, $6, $7, $8)")
|
("insert into BuildMetrics (build, name, unit, value, project, jobset, job, timestamp) values ($1, $2, $3, $4, $5, $6, $7, $8)")
|
||||||
|
|
Loading…
Reference in a new issue