@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.

Add support for a "containerPHID" in the worker queue

Summary:
Ref T13591. Worker queue tasks which affect commits currently (mostly) store the commit as an "objectPHID", but do not directly reference the repository the commit belongs to.

This can make certain operations (like "change the priority of all tasks affecting repository Y") more difficult than it needs to be.

Support a "containerPHID", similar to the field of the same name on builds, that can store a parent object like a repository and better support operations against subsets of tasks.

See also D11044 for the genesis of "objectPHID".

This depends on the introduction of storage patch phases (in D21529) so that earlier migrations which queue worker tasks don't try to insert this column before it actually exists.

Test Plan:
- Ran `bin/storage upgrade`.
- No callers yet, see further changes for usage.

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13591

Differential Revision: https://secure.phabricator.com/D21531

+16 -1
+5
resources/sql/autopatches/20210122.queuecontainer.01.sql
··· 1 + ALTER TABLE {$NAMESPACE}_worker.worker_activetask 2 + ADD containerPHID VARBINARY(64); 3 + 4 + ALTER TABLE {$NAMESPACE}_worker.worker_archivetask 5 + ADD containerPHID VARBINARY(64);
+4 -1
src/infrastructure/daemon/workers/PhabricatorWorker.php
··· 134 134 array( 135 135 'priority' => 'optional int|null', 136 136 'objectPHID' => 'optional string|null', 137 + 'containerPHID' => 'optional string|null', 137 138 'delayUntil' => 'optional int|null', 138 139 )); 139 140 ··· 142 143 $priority = self::PRIORITY_DEFAULT; 143 144 } 144 145 $object_phid = idx($options, 'objectPHID'); 146 + $container_phid = idx($options, 'containerPHID'); 145 147 146 148 $task = id(new PhabricatorWorkerActiveTask()) 147 149 ->setTaskClass($task_class) 148 150 ->setData($data) 149 151 ->setPriority($priority) 150 - ->setObjectPHID($object_phid); 152 + ->setObjectPHID($object_phid) 153 + ->setContainerPHID($container_phid); 151 154 152 155 $delay = idx($options, 'delayUntil'); 153 156 if ($delay) {
+1
src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php
··· 116 116 ->setDataID($this->getDataID()) 117 117 ->setPriority($this->getPriority()) 118 118 ->setObjectPHID($this->getObjectPHID()) 119 + ->setContainerPHID($this->getContainerPHID()) 119 120 ->setResult($result) 120 121 ->setDuration($duration) 121 122 ->setDateCreated($this->getDateCreated())
+1
src/infrastructure/daemon/workers/storage/PhabricatorWorkerArchiveTask.php
··· 87 87 ->setDataID($this->getDataID()) 88 88 ->setPriority($this->getPriority()) 89 89 ->setObjectPHID($this->getObjectPHID()) 90 + ->setContainerPHID($this->getContainerPHID()) 90 91 ->setDateCreated($this->getDateCreated()) 91 92 ->insert(); 92 93
+5
src/infrastructure/daemon/workers/storage/PhabricatorWorkerTask.php
··· 11 11 protected $dataID; 12 12 protected $priority; 13 13 protected $objectPHID; 14 + protected $containerPHID; 14 15 15 16 private $data; 16 17 private $executionException; ··· 25 26 'failureTime' => 'epoch?', 26 27 'priority' => 'uint32', 27 28 'objectPHID' => 'phid?', 29 + 'containerPHID' => 'phid?', 28 30 ), 29 31 self::CONFIG_KEY_SCHEMA => array( 30 32 'key_object' => array( 31 33 'columns' => array('objectPHID'), 34 + ), 35 + 'key_container' => array( 36 + 'columns' => array('containerPHID'), 32 37 ), 33 38 ), 34 39 ) + parent::getConfiguration();