Page MenuHomePhabricator

D21622.id51468.diff
No OneTemporary

D21622.id51468.diff

diff --git a/src/applications/harbormaster/editor/HarbormasterBuildTransactionEditor.php b/src/applications/harbormaster/editor/HarbormasterBuildTransactionEditor.php
--- a/src/applications/harbormaster/editor/HarbormasterBuildTransactionEditor.php
+++ b/src/applications/harbormaster/editor/HarbormasterBuildTransactionEditor.php
@@ -93,20 +93,37 @@
return;
}
- id(new HarbormasterBuildCommand())
+ // establish separate connection to avoid HarbormasterBuildCommand
+ // being created in transaction which already is happening, otherwise
+ // Worker can be started before HarbormasterBuildCommand is committed
+ $conn = id(new HarbormasterBuildCommand())
+ ->establishConnection('w', $force_new = true);
+
+ $build_command = id(new HarbormasterBuildCommand())
+ ->setForcedConnection($conn)
->setAuthorPHID($xaction->getAuthorPHID())
->setTargetPHID($build->getPHID())
->setCommand($command)
->save();
- PhabricatorWorker::scheduleTask(
- 'HarbormasterBuildWorker',
- array(
- 'buildID' => $build->getID(),
- ),
- array(
- 'objectPHID' => $build->getPHID(),
- ));
+ try {
+ PhabricatorWorker::scheduleTask(
+ 'HarbormasterBuildWorker',
+ array(
+ 'buildID' => $build->getID(),
+ ),
+ array(
+ 'objectPHID' => $build->getPHID(),
+ ));
+ } catch (Exception $e) {
+ // if we can't schedule task, let's delete command
+ $build_command->delete();
+ throw $e;
+ } catch (Throwable $e) {
+ // if we can't schedule task, let's delete command
+ $build_command->delete();
+ throw $e;
+ }
}
protected function applyCustomExternalTransaction(

File Metadata

Mime Type
text/plain
Expires
Jan 19 2026, 2:23 AM (7 w, 14 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
9002730
Default Alt Text
D21622.id51468.diff (1 KB)

Event Timeline