Skip to content

Commit 201e0d2

Browse files
author
epriestley
committedFeb 2, 2021
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
1 parent 32942f6 commit 201e0d2

File tree

5 files changed

+16
-1
lines changed

5 files changed

+16
-1
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
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);

‎src/infrastructure/daemon/workers/PhabricatorWorker.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ final public static function scheduleTask(
134134
array(
135135
'priority' => 'optional int|null',
136136
'objectPHID' => 'optional string|null',
137+
'containerPHID' => 'optional string|null',
137138
'delayUntil' => 'optional int|null',
138139
));
139140

@@ -142,12 +143,14 @@ final public static function scheduleTask(
142143
$priority = self::PRIORITY_DEFAULT;
143144
}
144145
$object_phid = idx($options, 'objectPHID');
146+
$container_phid = idx($options, 'containerPHID');
145147

146148
$task = id(new PhabricatorWorkerActiveTask())
147149
->setTaskClass($task_class)
148150
->setData($data)
149151
->setPriority($priority)
150-
->setObjectPHID($object_phid);
152+
->setObjectPHID($object_phid)
153+
->setContainerPHID($container_phid);
151154

152155
$delay = idx($options, 'delayUntil');
153156
if ($delay) {

‎src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public function archiveTask($result, $duration) {
116116
->setDataID($this->getDataID())
117117
->setPriority($this->getPriority())
118118
->setObjectPHID($this->getObjectPHID())
119+
->setContainerPHID($this->getContainerPHID())
119120
->setResult($result)
120121
->setDuration($duration)
121122
->setDateCreated($this->getDateCreated())

‎src/infrastructure/daemon/workers/storage/PhabricatorWorkerArchiveTask.php

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public function unarchiveTask() {
8787
->setDataID($this->getDataID())
8888
->setPriority($this->getPriority())
8989
->setObjectPHID($this->getObjectPHID())
90+
->setContainerPHID($this->getContainerPHID())
9091
->setDateCreated($this->getDateCreated())
9192
->insert();
9293

‎src/infrastructure/daemon/workers/storage/PhabricatorWorkerTask.php

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ abstract class PhabricatorWorkerTask extends PhabricatorWorkerDAO {
1111
protected $dataID;
1212
protected $priority;
1313
protected $objectPHID;
14+
protected $containerPHID;
1415

1516
private $data;
1617
private $executionException;
@@ -25,11 +26,15 @@ protected function getConfiguration() {
2526
'failureTime' => 'epoch?',
2627
'priority' => 'uint32',
2728
'objectPHID' => 'phid?',
29+
'containerPHID' => 'phid?',
2830
),
2931
self::CONFIG_KEY_SCHEMA => array(
3032
'key_object' => array(
3133
'columns' => array('objectPHID'),
3234
),
35+
'key_container' => array(
36+
'columns' => array('containerPHID'),
37+
),
3338
),
3439
) + parent::getConfiguration();
3540
}

0 commit comments

Comments
 (0)
Failed to load comments.