* (bug 27724) Add timestamp to job queue.
authorSam Reed <reedy@users.mediawiki.org>
Tue, 3 Jan 2012 15:08:05 +0000 (15:08 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Tue, 3 Jan 2012 15:08:05 +0000 (15:08 +0000)
Designed for administration purposes, not to be exposed to front end users

Useful for administration purposes (like WMF with job runners), we can look at the "highest" jobs, and find out whether enwiki is just busy, or the jobs have been there a while (signalling that the job runners potentially have issues)

RELEASE-NOTES-1.19
includes/installer/MysqlUpdater.php
includes/installer/SqliteUpdater.php
includes/job/JobQueue.php
maintenance/archives/patch-jobs-add-timestamp.sql [new file with mode: 0644]
maintenance/sqlite/archives/patch-jobs-add-timestamp.sql [new file with mode: 0644]
maintenance/tables.sql

index 9c8eec6..60fdd82 100644 (file)
@@ -109,8 +109,9 @@ production.
 * (bug 32512) Include 'associated namespace' checkbox on Special:Contributions
 * Added $wgSend404Code, true by default, which can be set to false to send a 
   200 status code instead of 404 for nonexistent articles.
-* (bug 23427) Introduced {{PAGEID}} variable to expose page.page_id
-* (bug 33447) Link to the broken image tracking category from Special:Wantedfiles
+* (bug 23427) Introduced {{PAGEID}} variable to expose page.page_id.
+* (bug 33447) Link to the broken image tracking category from Special:Wantedfiles.
+* (bug 27724) Add timestamp to job queue.
 
 === Bug fixes in 1.19 ===
 * $wgUploadNavigationUrl should be used for file redlinks if.
index 01dd28b..a5ffea4 100644 (file)
@@ -191,6 +191,7 @@ class MysqlUpdater extends DatabaseUpdater {
                        array( 'addIndex', 'page', 'page_redirect_namespace_len', 'patch-page_redirect_namespace_len.sql' ),
                        array( 'modifyField', 'user', 'ug_group', 'patch-ug_group-length-increase.sql' ),
                        array( 'addField',      'uploadstash',  'us_chunk_inx',         'patch-uploadstash_chunk.sql' ),
+                       array( 'addfield', 'job',           'job_timestamp',    'patch-jobs-add-timestamp.sql' ),
                );
        }
 
index 25592b2..fdb6437 100644 (file)
@@ -70,7 +70,7 @@ class SqliteUpdater extends DatabaseUpdater {
                        array( 'addIndex', 'page', 'page_redirect_namespace_len', 'patch-page_redirect_namespace_len.sql' ),
                        array( 'modifyField', 'user', 'ug_group', 'patch-ug_group-length-increase.sql' ),
                        array( 'addField',      'uploadstash',  'us_chunk_inx',         'patch-uploadstash_chunk.sql' ),
-
+                       array( 'addfield', 'job',           'job_timestamp',    'patch-jobs-add-timestamp.sql' ),
                );
        }
 
index bfaec33..1bc5d45 100644 (file)
@@ -252,6 +252,10 @@ abstract class Job {
                }
                $dbw = wfGetDB( DB_MASTER );
                $rows = array();
+
+               /**
+                * @var $job Job
+                */
                foreach ( $jobs as $job ) {
                        $rows[] = $job->insertFields();
                        if ( count( $rows ) >= 50 ) {
@@ -348,6 +352,7 @@ abstract class Job {
                        'job_cmd' => $this->command,
                        'job_namespace' => $this->title->getNamespace(),
                        'job_title' => $this->title->getDBkey(),
+                       'job_insert_timestamp' => wfTimestampNow(),
                        'job_params' => Job::makeBlob( $this->params )
                );
        }
diff --git a/maintenance/archives/patch-jobs-add-timestamp.sql b/maintenance/archives/patch-jobs-add-timestamp.sql
new file mode 100644 (file)
index 0000000..c5e6e71
--- /dev/null
@@ -0,0 +1,2 @@
+ALTER TABLE /*_*/job ADD COLUMN job_timestamp varbinary(14) NULL default NULL;
+CREATE INDEX /*i*/job_timestamp ON /*_*/job(job_timestamp);
diff --git a/maintenance/sqlite/archives/patch-jobs-add-timestamp.sql b/maintenance/sqlite/archives/patch-jobs-add-timestamp.sql
new file mode 100644 (file)
index 0000000..c5e6e71
--- /dev/null
@@ -0,0 +1,2 @@
+ALTER TABLE /*_*/job ADD COLUMN job_timestamp varbinary(14) NULL default NULL;
+CREATE INDEX /*i*/job_timestamp ON /*_*/job(job_timestamp);
index 3655018..3f7f1a3 100644 (file)
@@ -1263,12 +1263,17 @@ CREATE TABLE /*_*/job (
   job_namespace int NOT NULL,
   job_title varchar(255) binary NOT NULL,
 
+  -- Timestamp of when the job was inserted
+  -- NULL for jobs added before addition of the timestamp
+  job_timestamp varbinary(14) NULL default NULL,
+
   -- Any other parameters to the command
   -- Stored as a PHP serialized array, or an empty string if there are no parameters
   job_params blob NOT NULL
 ) /*$wgDBTableOptions*/;
 
 CREATE INDEX /*i*/job_cmd ON /*_*/job (job_cmd, job_namespace, job_title, job_params(128));
+CREATE INDEX /*i*/job_insert_timestamp ON /*_*/job(job_insert_timestamp);
 
 
 -- Details of updates to cached special pages