@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+51 -31
+4
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 585 585 'a race?')); 586 586 } 587 587 588 + // TODO: This can race with diff updates, particularly those from 589 + // Harbormaster. See discussion in T8650. 588 590 $diff->setRevisionID($object->getID()); 589 591 $diff->save(); 590 592 ··· 593 595 // the old (`null`) container. 594 596 595 597 // TODO: This is a bit iffy, maybe we can find a cleaner approach? 598 + // In particular, this could (rarely) be overwritten by Harbormaster 599 + // workers. 596 600 $table = new HarbormasterBuildable(); 597 601 $conn_w = $table->establishConnection('w'); 598 602 queryfx(
+47 -31
src/applications/harbormaster/engine/HarbormasterBuildEngine.php
··· 406 406 $should_publish = $did_update && 407 407 $new_status != HarbormasterBuildable::STATUS_BUILDING && 408 408 !$buildable->getIsManualBuildable(); 409 - if ($should_publish) { 410 - $object = id(new PhabricatorObjectQuery()) 411 - ->setViewer($viewer) 412 - ->withPHIDs(array($buildable->getBuildablePHID())) 413 - ->executeOne(); 414 409 415 - if ($object instanceof PhabricatorApplicationTransactionInterface) { 416 - $template = $object->getApplicationTransactionTemplate(); 417 - if ($template) { 418 - $template 419 - ->setTransactionType(PhabricatorTransactions::TYPE_BUILDABLE) 420 - ->setMetadataValue( 421 - 'harbormaster:buildablePHID', 422 - $buildable->getPHID()) 423 - ->setOldValue($old_status) 424 - ->setNewValue($new_status); 410 + if (!$should_publish) { 411 + return; 412 + } 425 413 426 - $harbormaster_phid = id(new PhabricatorHarbormasterApplication()) 427 - ->getPHID(); 414 + $object = id(new PhabricatorObjectQuery()) 415 + ->setViewer($viewer) 416 + ->withPHIDs(array($buildable->getBuildablePHID())) 417 + ->executeOne(); 418 + if (!$object) { 419 + return; 420 + } 428 421 429 - $daemon_source = PhabricatorContentSource::newForSource( 430 - PhabricatorContentSource::SOURCE_DAEMON, 431 - array()); 422 + if (!($object instanceof PhabricatorApplicationTransactionInterface)) { 423 + return; 424 + } 432 425 433 - $editor = $object->getApplicationTransactionEditor() 434 - ->setActor($viewer) 435 - ->setActingAsPHID($harbormaster_phid) 436 - ->setContentSource($daemon_source) 437 - ->setContinueOnNoEffect(true) 438 - ->setContinueOnMissingFields(true); 426 + // TODO: Publishing these transactions is causing a race. See T8650. 427 + // We shouldn't be publishing to diffs anyway. 428 + if ($object instanceof DifferentialDiff) { 429 + return; 430 + } 439 431 440 - $editor->applyTransactions( 441 - $object->getApplicationTransactionObject(), 442 - array($template)); 443 - } 444 - } 432 + $template = $object->getApplicationTransactionTemplate(); 433 + if (!$template) { 434 + return; 445 435 } 436 + 437 + $template 438 + ->setTransactionType(PhabricatorTransactions::TYPE_BUILDABLE) 439 + ->setMetadataValue( 440 + 'harbormaster:buildablePHID', 441 + $buildable->getPHID()) 442 + ->setOldValue($old_status) 443 + ->setNewValue($new_status); 444 + 445 + $harbormaster_phid = id(new PhabricatorHarbormasterApplication()) 446 + ->getPHID(); 447 + 448 + $daemon_source = PhabricatorContentSource::newForSource( 449 + PhabricatorContentSource::SOURCE_DAEMON, 450 + array()); 451 + 452 + $editor = $object->getApplicationTransactionEditor() 453 + ->setActor($viewer) 454 + ->setActingAsPHID($harbormaster_phid) 455 + ->setContentSource($daemon_source) 456 + ->setContinueOnNoEffect(true) 457 + ->setContinueOnMissingFields(true); 458 + 459 + $editor->applyTransactions( 460 + $object->getApplicationTransactionObject(), 461 + array($template)); 446 462 } 447 463 448 464 private function releaseAllArtifacts(HarbormasterBuild $build) {