r107886 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107885‎ | r107886 | r107887 >
Date:15:08, 3 January 2012
Author:reedy
Status:resolved (Comments)
Tags:schema 
Comment:
* (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)
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/includes/installer/MysqlUpdater.php (modified) (history)
  • /trunk/phase3/includes/installer/SqliteUpdater.php (modified) (history)
  • /trunk/phase3/includes/job/JobQueue.php (modified) (history)
  • /trunk/phase3/maintenance/archives/patch-jobs-add-timestamp.sql (added) (history)
  • /trunk/phase3/maintenance/sqlite/archives/patch-jobs-add-timestamp.sql (added) (history)
  • /trunk/phase3/maintenance/tables.sql (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tables.sql
@@ -1263,12 +1263,17 @@
12641264 job_namespace int NOT NULL,
12651265 job_title varchar(255) binary NOT NULL,
12661266
 1267+ -- Timestamp of when the job was inserted
 1268+ -- NULL for jobs added before addition of the timestamp
 1269+ job_timestamp varbinary(14) NULL default NULL,
 1270+
12671271 -- Any other parameters to the command
12681272 -- Stored as a PHP serialized array, or an empty string if there are no parameters
12691273 job_params blob NOT NULL
12701274 ) /*$wgDBTableOptions*/;
12711275
12721276 CREATE INDEX /*i*/job_cmd ON /*_*/job (job_cmd, job_namespace, job_title, job_params(128));
 1277+CREATE INDEX /*i*/job_insert_timestamp ON /*_*/job(job_insert_timestamp);
12731278
12741279
12751280 -- Details of updates to cached special pages
Index: trunk/phase3/maintenance/sqlite/archives/patch-jobs-add-timestamp.sql
@@ -0,0 +1,2 @@
 2+ALTER TABLE /*_*/job ADD COLUMN job_timestamp varbinary(14) NULL default NULL;
 3+CREATE INDEX /*i*/job_timestamp ON /*_*/job(job_timestamp);
Property changes on: trunk/phase3/maintenance/sqlite/archives/patch-jobs-add-timestamp.sql
___________________________________________________________________
Added: svn:eol-style
14 + native
Index: trunk/phase3/maintenance/archives/patch-jobs-add-timestamp.sql
@@ -0,0 +1,2 @@
 2+ALTER TABLE /*_*/job ADD COLUMN job_timestamp varbinary(14) NULL default NULL;
 3+CREATE INDEX /*i*/job_timestamp ON /*_*/job(job_timestamp);
Property changes on: trunk/phase3/maintenance/archives/patch-jobs-add-timestamp.sql
___________________________________________________________________
Added: svn:eol-style
14 + native
Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -109,8 +109,9 @@
110110 * (bug 32512) Include 'associated namespace' checkbox on Special:Contributions
111111 * Added $wgSend404Code, true by default, which can be set to false to send a
112112 200 status code instead of 404 for nonexistent articles.
113 -* (bug 23427) Introduced {{PAGEID}} variable to expose page.page_id
114 -* (bug 33447) Link to the broken image tracking category from Special:Wantedfiles
 113+* (bug 23427) Introduced {{PAGEID}} variable to expose page.page_id.
 114+* (bug 33447) Link to the broken image tracking category from Special:Wantedfiles.
 115+* (bug 27724) Add timestamp to job queue.
115116
116117 === Bug fixes in 1.19 ===
117118 * $wgUploadNavigationUrl should be used for file redlinks if.
Index: trunk/phase3/includes/job/JobQueue.php
@@ -252,6 +252,10 @@
253253 }
254254 $dbw = wfGetDB( DB_MASTER );
255255 $rows = array();
 256+
 257+ /**
 258+ * @var $job Job
 259+ */
256260 foreach ( $jobs as $job ) {
257261 $rows[] = $job->insertFields();
258262 if ( count( $rows ) >= 50 ) {
@@ -348,6 +352,7 @@
349353 'job_cmd' => $this->command,
350354 'job_namespace' => $this->title->getNamespace(),
351355 'job_title' => $this->title->getDBkey(),
 356+ 'job_insert_timestamp' => wfTimestampNow(),
352357 'job_params' => Job::makeBlob( $this->params )
353358 );
354359 }
Index: trunk/phase3/includes/installer/SqliteUpdater.php
@@ -70,7 +70,7 @@
7171 array( 'addIndex', 'page', 'page_redirect_namespace_len', 'patch-page_redirect_namespace_len.sql' ),
7272 array( 'modifyField', 'user', 'ug_group', 'patch-ug_group-length-increase.sql' ),
7373 array( 'addField', 'uploadstash', 'us_chunk_inx', 'patch-uploadstash_chunk.sql' ),
74 -
 74+ array( 'addfield', 'job', 'job_timestamp', 'patch-jobs-add-timestamp.sql' ),
7575 );
7676 }
7777
Index: trunk/phase3/includes/installer/MysqlUpdater.php
@@ -191,6 +191,7 @@
192192 array( 'addIndex', 'page', 'page_redirect_namespace_len', 'patch-page_redirect_namespace_len.sql' ),
193193 array( 'modifyField', 'user', 'ug_group', 'patch-ug_group-length-increase.sql' ),
194194 array( 'addField', 'uploadstash', 'us_chunk_inx', 'patch-uploadstash_chunk.sql' ),
 195+ array( 'addfield', 'job', 'job_timestamp', 'patch-jobs-add-timestamp.sql' ),
195196 );
196197 }
197198

Follow-up revisions

RevisionCommit summaryAuthorDate
r107887Fix non reverted job_insert_timestamp...reedy15:14, 3 January 2012

Comments

#Comment by Reedy (talk | contribs)   15:09, 3 January 2012

ALSO!

I added the index, as someone is likely to do SELECT * FROM job ORDER BY job_timestamp, you just know it's gonna happen

#Comment by Catrope (talk | contribs)   15:10, 3 January 2012
+			'job_insert_timestamp' => wfTimestampNow(),

Needs to be $db->timestamp() . OK otherwise.

Status & tagging log