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

Correct schema irregularities (including weird keys) with worker task tables

Summary:
Ref T13253. Fixes T6615. See that task for discussion.

- Remove three keys which serve no real purpose: `dataID` doesn't do anything for us, and the two `leaseOwner` keys are unused.
- Rename `leaseOwner_2` to `key_owner`.
- Fix an issue where `dataID` was nullable in the active table and non-nullable in the archive table.

In practice, //all// workers have data, so all workers have a `dataID`: if they didn't, we'd already fatal when trying to move tasks to the archive table. Just clean this up for consistency, and remove the ancient codepath which imagined tasks with no data.

Test Plan:
- Ran `bin/storage upgrade`, inspected tables.
- Ran `bin/phd debug taskmaster`, worked through a bunch of tasks with no problems.

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13253, T6615

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

+25 -19
+21
resources/sql/autopatches/20190215.daemons.01.dropdataid.php
··· 1 + <?php 2 + 3 + // See T6615. We're about to change the nullability on the "dataID" column, 4 + // but it may have a UNIQUE KEY on it. Make sure we get rid of this key first 5 + // so we don't run into trouble. 6 + 7 + // There's no "IF EXISTS" modifier for "ALTER TABLE" so run this as a PHP patch 8 + // instead of an SQL patch. 9 + 10 + $table = new PhabricatorWorkerActiveTask(); 11 + $conn = $table->establishConnection('w'); 12 + 13 + try { 14 + queryfx( 15 + $conn, 16 + 'ALTER TABLE %R DROP KEY %T', 17 + $table, 18 + 'dataID'); 19 + } catch (AphrontQueryException $ex) { 20 + // Ignore. 21 + }
+2
resources/sql/autopatches/20190215.daemons.02.nulldataid.sql
··· 1 + ALTER TABLE {$NAMESPACE}_worker.worker_activetask 2 + CHANGE dataID dataID INT UNSIGNED NOT NULL;
+2 -16
src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php
··· 14 14 self::CONFIG_IDS => self::IDS_COUNTER, 15 15 self::CONFIG_TIMESTAMPS => false, 16 16 self::CONFIG_KEY_SCHEMA => array( 17 - 'dataID' => array( 18 - 'columns' => array('dataID'), 19 - 'unique' => true, 20 - ), 21 17 'taskClass' => array( 22 18 'columns' => array('taskClass'), 23 19 ), 24 20 'leaseExpires' => array( 25 21 'columns' => array('leaseExpires'), 26 22 ), 27 - 'leaseOwner' => array( 28 - 'columns' => array('leaseOwner(16)'), 29 - ), 30 23 'key_failuretime' => array( 31 24 'columns' => array('failureTime'), 32 25 ), 33 - 'leaseOwner_2' => array( 26 + 'key_owner' => array( 34 27 'columns' => array('leaseOwner', 'priority', 'id'), 35 28 ), 36 29 ) + $parent[self::CONFIG_KEY_SCHEMA], 37 30 ); 38 - 39 - $config[self::CONFIG_COLUMN_SCHEMA] = array( 40 - // T6203/NULLABILITY 41 - // This isn't nullable in the archive table, so at a minimum these 42 - // should be the same. 43 - 'dataID' => 'uint32?', 44 - ) + $parent[self::CONFIG_COLUMN_SCHEMA]; 45 31 46 32 return $config + $parent; 47 33 } ··· 74 60 $this->failureCount = 0; 75 61 } 76 62 77 - if ($is_new && ($this->getData() !== null)) { 63 + if ($is_new) { 78 64 $data = new PhabricatorWorkerTaskData(); 79 65 $data->setData($this->getData()); 80 66 $data->save();
-3
src/infrastructure/daemon/workers/storage/PhabricatorWorkerArchiveTask.php
··· 28 28 'dateCreated' => array( 29 29 'columns' => array('dateCreated'), 30 30 ), 31 - 'leaseOwner' => array( 32 - 'columns' => array('leaseOwner', 'priority', 'id'), 33 - ), 34 31 'key_modified' => array( 35 32 'columns' => array('dateModified'), 36 33 ),