1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 03:50:54 +01:00

Carefully avoid the harbormaster/differential race

Summary: Ref T8650. This should stop the problem, but isn't a root cause fix. See discussion on the task.

Test Plan: Made some local diffs, but this is a bit hard to reproduce reliably.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8650

Differential Revision: https://secure.phabricator.com/D13441
This commit is contained in:
epriestley 2015-06-25 10:05:37 -07:00
parent 5f99d79c5d
commit db1bc7fd7f
2 changed files with 55 additions and 35 deletions

View file

@ -585,6 +585,8 @@ final class DifferentialTransactionEditor
'a race?')); 'a race?'));
} }
// TODO: This can race with diff updates, particularly those from
// Harbormaster. See discussion in T8650.
$diff->setRevisionID($object->getID()); $diff->setRevisionID($object->getID());
$diff->save(); $diff->save();
@ -593,6 +595,8 @@ final class DifferentialTransactionEditor
// the old (`null`) container. // the old (`null`) container.
// TODO: This is a bit iffy, maybe we can find a cleaner approach? // TODO: This is a bit iffy, maybe we can find a cleaner approach?
// In particular, this could (rarely) be overwritten by Harbormaster
// workers.
$table = new HarbormasterBuildable(); $table = new HarbormasterBuildable();
$conn_w = $table->establishConnection('w'); $conn_w = $table->establishConnection('w');
queryfx( queryfx(

View file

@ -406,15 +406,34 @@ final class HarbormasterBuildEngine extends Phobject {
$should_publish = $did_update && $should_publish = $did_update &&
$new_status != HarbormasterBuildable::STATUS_BUILDING && $new_status != HarbormasterBuildable::STATUS_BUILDING &&
!$buildable->getIsManualBuildable(); !$buildable->getIsManualBuildable();
if ($should_publish) {
if (!$should_publish) {
return;
}
$object = id(new PhabricatorObjectQuery()) $object = id(new PhabricatorObjectQuery())
->setViewer($viewer) ->setViewer($viewer)
->withPHIDs(array($buildable->getBuildablePHID())) ->withPHIDs(array($buildable->getBuildablePHID()))
->executeOne(); ->executeOne();
if (!$object) {
return;
}
if (!($object instanceof PhabricatorApplicationTransactionInterface)) {
return;
}
// TODO: Publishing these transactions is causing a race. See T8650.
// We shouldn't be publishing to diffs anyway.
if ($object instanceof DifferentialDiff) {
return;
}
if ($object instanceof PhabricatorApplicationTransactionInterface) {
$template = $object->getApplicationTransactionTemplate(); $template = $object->getApplicationTransactionTemplate();
if ($template) { if (!$template) {
return;
}
$template $template
->setTransactionType(PhabricatorTransactions::TYPE_BUILDABLE) ->setTransactionType(PhabricatorTransactions::TYPE_BUILDABLE)
->setMetadataValue( ->setMetadataValue(
@ -441,9 +460,6 @@ final class HarbormasterBuildEngine extends Phobject {
$object->getApplicationTransactionObject(), $object->getApplicationTransactionObject(),
array($template)); array($template));
} }
}
}
}
private function releaseAllArtifacts(HarbormasterBuild $build) { private function releaseAllArtifacts(HarbormasterBuild $build) {
$targets = id(new HarbormasterBuildTargetQuery()) $targets = id(new HarbormasterBuildTargetQuery())