From faca3cb2e78153f684f1af7b88747e1bc828f743 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Tue, 3 Jan 2012 15:08:05 +0000 Subject: [PATCH] * (bug 27724) Add timestamp to job queue. 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 | 5 +++-- includes/installer/MysqlUpdater.php | 1 + includes/installer/SqliteUpdater.php | 2 +- includes/job/JobQueue.php | 5 +++++ maintenance/archives/patch-jobs-add-timestamp.sql | 2 ++ maintenance/sqlite/archives/patch-jobs-add-timestamp.sql | 2 ++ maintenance/tables.sql | 5 +++++ 7 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 maintenance/archives/patch-jobs-add-timestamp.sql create mode 100644 maintenance/sqlite/archives/patch-jobs-add-timestamp.sql diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index 9c8eec63b2..60fdd82cd4 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -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. diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php index 01dd28b865..a5ffea4e24 100644 --- a/includes/installer/MysqlUpdater.php +++ b/includes/installer/MysqlUpdater.php @@ -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' ), ); } diff --git a/includes/installer/SqliteUpdater.php b/includes/installer/SqliteUpdater.php index 25592b2905..fdb64378cd 100644 --- a/includes/installer/SqliteUpdater.php +++ b/includes/installer/SqliteUpdater.php @@ -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' ), ); } diff --git a/includes/job/JobQueue.php b/includes/job/JobQueue.php index bfaec33cf5..1bc5d456cb 100644 --- a/includes/job/JobQueue.php +++ b/includes/job/JobQueue.php @@ -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 index 0000000000..c5e6e7110b --- /dev/null +++ b/maintenance/archives/patch-jobs-add-timestamp.sql @@ -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 index 0000000000..c5e6e7110b --- /dev/null +++ b/maintenance/sqlite/archives/patch-jobs-add-timestamp.sql @@ -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/tables.sql b/maintenance/tables.sql index 3655018bf8..3f7f1a327c 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -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 -- 2.20.1