Fix several migration issues with the Task/Counter patch
Summary:
People hit three issues with D3914:
- As per T2059, we applied a schema change from a `.php` patch, which currently does not work if you use a different user to make schema changes than for normal use.
- Since the change in question is idempotent, just move it to a `.sql` patch. We'll follow up in T2059 and fix it properly.
- Rogue daemons at several installs used old code (expecting autoincrement) to insert into the new table (no autoincrement), thereby creating tasks with ID 0.
- Rename the table so they'll fail.
- This also makes the code a little more consistent.
- Some installs now have tasks with ID 0.
- Use checks against null rather than against 0 so we can process these tasks.
The major issues this fixes are the schema upgrade failure in T2059, and the infinite loops in T2072 and elsewhere.
This isn't really a fully statisfactory fix. I'll discuss some next steps in T2072.
Test Plan: Created new tasks via MetaMTA/Differential. Ran tasks with `phd debug taskmaster`. Inserted a task 0 and verified it ran and archived correctly.
Reviewers: btrahan, vrana, nh
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2072, T2059
Differential Revision: https://secure.phabricator.com/D3973
This commit is contained in:
@@ -5,10 +5,6 @@ final class PhabricatorWorkerActiveTask extends PhabricatorWorkerTask {
|
||||
private $serverTime;
|
||||
private $localTime;
|
||||
|
||||
public function getTableName() {
|
||||
return 'worker_task';
|
||||
}
|
||||
|
||||
public function getConfiguration() {
|
||||
return array(
|
||||
self::CONFIG_IDS => self::IDS_COUNTER,
|
||||
@@ -71,7 +67,7 @@ final class PhabricatorWorkerActiveTask extends PhabricatorWorkerTask {
|
||||
}
|
||||
|
||||
public function archiveTask($result, $duration) {
|
||||
if (!$this->getID()) {
|
||||
if ($this->getID() === null) {
|
||||
throw new Exception(
|
||||
"Attempting to archive a task which hasn't been save()d!");
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ final class PhabricatorWorkerArchiveTask extends PhabricatorWorkerTask {
|
||||
protected $result;
|
||||
|
||||
public function save() {
|
||||
if (!$this->getID()) {
|
||||
if ($this->getID() === null) {
|
||||
throw new Exception(
|
||||
"Trying to archive a task with no ID.");
|
||||
}
|
||||
|
||||
@@ -1028,6 +1028,10 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList {
|
||||
'type' => 'sql',
|
||||
'name' => $this->getPatchPath('repository-lint.sql'),
|
||||
),
|
||||
'liskcounters-task.sql' => array(
|
||||
'type' => 'sql',
|
||||
'name' => $this->getPatchPath('liskcounters-task.sql'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user