Page MenuHomePhabricator

D11044.diff
No OneTemporary

D11044.diff

diff --git a/resources/sql/autopatches/20141223.daemonobjectphid.sql b/resources/sql/autopatches/20141223.daemonobjectphid.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20141223.daemonobjectphid.sql
@@ -0,0 +1,5 @@
+ALTER TABLE {$NAMESPACE}_worker.worker_activetask
+ ADD objectPHID VARBINARY(64);
+
+ALTER TABLE {$NAMESPACE}_worker.worker_archivetask
+ ADD objectPHID VARBINARY(64);
diff --git a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php
--- a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php
+++ b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php
@@ -188,7 +188,9 @@
'emailPHIDs' => array_values($this->emailPHIDs),
'info' => $this->loadCommitInfoForWorker($all_updates),
),
- PhabricatorWorker::PRIORITY_ALERTS);
+ array(
+ 'priority' => PhabricatorWorker::PRIORITY_ALERTS,
+ ));
}
return 0;
diff --git a/src/applications/metamta/management/PhabricatorMailManagementResendWorkflow.php b/src/applications/metamta/management/PhabricatorMailManagementResendWorkflow.php
--- a/src/applications/metamta/management/PhabricatorMailManagementResendWorkflow.php
+++ b/src/applications/metamta/management/PhabricatorMailManagementResendWorkflow.php
@@ -50,7 +50,9 @@
$mailer_task = PhabricatorWorker::scheduleTask(
'PhabricatorMetaMTAWorker',
$message->getID(),
- PhabricatorWorker::PRIORITY_ALERTS);
+ array(
+ 'priority' => PhabricatorWorker::PRIORITY_ALERTS,
+ ));
$console->writeOut(
"Queued message #%d for resend.\n",
diff --git a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php
--- a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php
+++ b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php
@@ -342,7 +342,9 @@
$mailer_task = PhabricatorWorker::scheduleTask(
'PhabricatorMetaMTAWorker',
$this->getID(),
- PhabricatorWorker::PRIORITY_ALERTS);
+ array(
+ 'priority' => PhabricatorWorker::PRIORITY_ALERTS,
+ ));
$this->saveTransaction();
diff --git a/src/applications/search/index/PhabricatorSearchIndexer.php b/src/applications/search/index/PhabricatorSearchIndexer.php
--- a/src/applications/search/index/PhabricatorSearchIndexer.php
+++ b/src/applications/search/index/PhabricatorSearchIndexer.php
@@ -8,7 +8,9 @@
array(
'documentPHID' => $phid,
),
- PhabricatorWorker::PRIORITY_IMPORT);
+ array(
+ 'priority' => PhabricatorWorker::PRIORITY_IMPORT,
+ ));
}
public function indexDocumentByPHID($phid) {
diff --git a/src/infrastructure/daemon/workers/PhabricatorWorker.php b/src/infrastructure/daemon/workers/PhabricatorWorker.php
--- a/src/infrastructure/daemon/workers/PhabricatorWorker.php
+++ b/src/infrastructure/daemon/workers/PhabricatorWorker.php
@@ -94,16 +94,19 @@
final public static function scheduleTask(
$task_class,
$data,
- $priority = null) {
+ $options = array()) {
+ $priority = idx($options, 'priority');
if ($priority === null) {
$priority = self::PRIORITY_DEFAULT;
}
+ $object_phid = idx($options, 'objectPHID');
$task = id(new PhabricatorWorkerActiveTask())
->setTaskClass($task_class)
->setData($data)
- ->setPriority($priority);
+ ->setPriority($priority)
+ ->setObjectPHID($object_phid);
if (self::$runAllTasksInProcess) {
// Do the work in-process.
@@ -114,7 +117,8 @@
$worker->doWork();
foreach ($worker->getQueuedTasks() as $queued_task) {
list($queued_class, $queued_data, $queued_priority) = $queued_task;
- self::scheduleTask($queued_class, $queued_data, $queued_priority);
+ $queued_options = array('priority' => $queued_priority);
+ self::scheduleTask($queued_class, $queued_data, $queued_options);
}
break;
} catch (PhabricatorWorkerYieldException $ex) {
diff --git a/src/infrastructure/daemon/workers/__tests__/PhabricatorWorkerTestCase.php b/src/infrastructure/daemon/workers/__tests__/PhabricatorWorkerTestCase.php
--- a/src/infrastructure/daemon/workers/__tests__/PhabricatorWorkerTestCase.php
+++ b/src/infrastructure/daemon/workers/__tests__/PhabricatorWorkerTestCase.php
@@ -206,7 +206,7 @@
return PhabricatorWorker::scheduleTask(
'PhabricatorTestWorker',
$data,
- $priority);
+ array('priority' => $priority));
}
}
diff --git a/src/infrastructure/daemon/workers/query/PhabricatorWorkerLeaseQuery.php b/src/infrastructure/daemon/workers/query/PhabricatorWorkerLeaseQuery.php
--- a/src/infrastructure/daemon/workers/query/PhabricatorWorkerLeaseQuery.php
+++ b/src/infrastructure/daemon/workers/query/PhabricatorWorkerLeaseQuery.php
@@ -9,6 +9,7 @@
const PHASE_EXPIRED = 'expired';
private $ids;
+ private $objectPHIDs;
private $limit;
private $skipLease;
@@ -39,6 +40,11 @@
return $this;
}
+ public function withObjectPHIDs(array $phids) {
+ $this->objectPHIDs = $phids;
+ return $this;
+ }
+
public function setLimit($limit) {
$this->limit = $limit;
return $this;
@@ -175,6 +181,10 @@
$where[] = qsprintf($conn_w, 'id IN (%Ld)', $this->ids);
}
+ if ($this->objectPHIDs !== null) {
+ $where[] = qsprintf($conn_w, 'objectPHID IN (%Ls)', $this->objectPHIDs);
+ }
+
return $this->formatWhereClause($where);
}
diff --git a/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php b/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php
--- a/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php
+++ b/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php
@@ -33,7 +33,7 @@
'leaseOwner_2' => array(
'columns' => array('leaseOwner', 'priority', 'id'),
),
- ),
+ ) + $parent[self::CONFIG_KEY_SCHEMA],
);
$config[self::CONFIG_COLUMN_SCHEMA] = array(
@@ -197,7 +197,12 @@
if ($did_succeed) {
foreach ($worker->getQueuedTasks() as $task) {
list($class, $data) = $task;
- PhabricatorWorker::scheduleTask($class, $data, $this->getPriority());
+ PhabricatorWorker::scheduleTask(
+ $class,
+ $data,
+ array(
+ 'priority' => $this->getPriority(),
+ ));
}
}
diff --git a/src/infrastructure/daemon/workers/storage/PhabricatorWorkerArchiveTask.php b/src/infrastructure/daemon/workers/storage/PhabricatorWorkerArchiveTask.php
--- a/src/infrastructure/daemon/workers/storage/PhabricatorWorkerArchiveTask.php
+++ b/src/infrastructure/daemon/workers/storage/PhabricatorWorkerArchiveTask.php
@@ -10,11 +10,13 @@
protected $result;
public function getConfiguration() {
+ $parent = parent::getConfiguration();
+
$config = array(
// We manage the IDs in this table; they are allocated in the ActiveTask
// table and moved here without alteration.
self::CONFIG_IDS => self::IDS_MANUAL,
- ) + parent::getConfiguration();
+ ) + $parent;
$config[self::CONFIG_COLUMN_SCHEMA] = array(
@@ -29,7 +31,7 @@
'leaseOwner' => array(
'columns' => array('leaseOwner', 'priority', 'id'),
),
- );
+ ) + $parent[self::CONFIG_KEY_SCHEMA];
return $config;
}
diff --git a/src/infrastructure/daemon/workers/storage/PhabricatorWorkerTask.php b/src/infrastructure/daemon/workers/storage/PhabricatorWorkerTask.php
--- a/src/infrastructure/daemon/workers/storage/PhabricatorWorkerTask.php
+++ b/src/infrastructure/daemon/workers/storage/PhabricatorWorkerTask.php
@@ -10,6 +10,7 @@
protected $failureCount;
protected $dataID;
protected $priority;
+ protected $objectPHID;
private $data;
private $executionException;
@@ -23,6 +24,12 @@
'failureCount' => 'uint32',
'failureTime' => 'epoch?',
'priority' => 'uint32',
+ 'objectPHID' => 'phid?',
+ ),
+ self::CONFIG_KEY_SCHEMA => array(
+ 'key_object' => array(
+ 'columns' => array('objectPHID'),
+ ),
),
) + parent::getConfiguration();
}
diff --git a/src/infrastructure/sms/adapter/PhabricatorSMSImplementationAdapter.php b/src/infrastructure/sms/adapter/PhabricatorSMSImplementationAdapter.php
--- a/src/infrastructure/sms/adapter/PhabricatorSMSImplementationAdapter.php
+++ b/src/infrastructure/sms/adapter/PhabricatorSMSImplementationAdapter.php
@@ -81,6 +81,8 @@
'toNumbers' => $to_numbers,
'body' => $body,
),
- PhabricatorWorker::PRIORITY_ALERTS);
+ array(
+ 'priority' => PhabricatorWorker::PRIORITY_ALERTS,
+ ));
}
}

File Metadata

Mime Type
text/plain
Expires
Sat, Apr 5, 4:20 PM (2 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7332577
Default Alt Text
D11044.diff (8 KB)

Event Timeline