Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15407933
D10895.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D10895.diff
View Options
diff --git a/resources/sql/autopatches/20141123.taskpriority.1.sql b/resources/sql/autopatches/20141123.taskpriority.1.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20141123.taskpriority.1.sql
@@ -0,0 +1,2 @@
+UPDATE {$NAMESPACE}_worker.worker_activetask
+ SET priority = 5000 - priority;
diff --git a/resources/sql/autopatches/20141123.taskpriority.2.sql b/resources/sql/autopatches/20141123.taskpriority.2.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20141123.taskpriority.2.sql
@@ -0,0 +1,2 @@
+UPDATE {$NAMESPACE}_worker.worker_archivetask
+ SET priority = 5000 - priority;
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
@@ -9,10 +9,14 @@
private static $runAllTasksInProcess = false;
private $queuedTasks = array();
- const PRIORITY_ALERTS = 4000;
- const PRIORITY_DEFAULT = 3000;
- const PRIORITY_BULK = 2000;
- const PRIORITY_IMPORT = 1000;
+ // NOTE: Lower priority numbers execute first. The priority numbers have to
+ // have the same ordering that IDs do (lowest first) so MySQL can use a
+ // multipart key across both of them efficiently.
+
+ const PRIORITY_ALERTS = 1000;
+ const PRIORITY_DEFAULT = 2000;
+ const PRIORITY_BULK = 3000;
+ const PRIORITY_IMPORT = 4000;
/* -( Configuring Retries and Failures )----------------------------------- */
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
@@ -160,14 +160,14 @@
$this->expectNextLease($task1);
}
- public function testLeasedIsHighestPriority() {
- $task1 = $this->scheduleTask(array(), 1);
- $task2 = $this->scheduleTask(array(), 1);
- $task3 = $this->scheduleTask(array(), 2);
+ public function testLeasedIsLowestPriority() {
+ $task1 = $this->scheduleTask(array(), 2);
+ $task2 = $this->scheduleTask(array(), 2);
+ $task3 = $this->scheduleTask(array(), 1);
$this->expectNextLease(
$task3,
- 'Tasks with a higher priority should be scheduled first.');
+ 'Tasks with a lower priority should be scheduled first.');
$this->expectNextLease(
$task1,
'Tasks with the same priority should be FIFO.');
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
@@ -215,8 +215,8 @@
switch ($phase) {
case self::PHASE_UNLEASED:
// When selecting new tasks, we want to consume them in order of
- // decreasing priority (and then FIFO).
- return qsprintf($conn_w, 'ORDER BY priority DESC, id ASC');
+ // increasing priority (and then FIFO).
+ return qsprintf($conn_w, 'ORDER BY priority ASC, id ASC');
case self::PHASE_EXPIRED:
// When selecting failed tasks, we want to consume them in roughly
// FIFO order of their failures, which is not necessarily their original
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 19, 8:17 PM (3 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7493214
Default Alt Text
D10895.diff (3 KB)
Attached To
Mode
D10895: Reverse meaning of task priority column
Attached
Detach File
Event Timeline
Log In to Comment