Added $wgRunJobsAsync to allow running jobs the old way
authorJesús Martínez Novo <martineznovo@gmail.com>
Mon, 7 Apr 2014 21:13:25 +0000 (23:13 +0200)
committerJesús Martínez Novo <martineznovo@gmail.com>
Wed, 9 Apr 2014 19:25:59 +0000 (21:25 +0200)
Adding a new global variable (DefaultSettings.php) named $wgRunJobsAsync, that
defaults to true, to allow installations to force the old synchronous job
execution on page requests instead of the new asynchonous one.

The asynchronous job queue execution was added in 1.22, executing a new shell
script, and it caused major problems for third party installations with restricted
environments or limited system resources, and also because a lot of bugs that went
unnoticed because WMF wikis do not use the on-request job queue.

In 1.23 it was changed to use a new internal HTTP request to a MediaWiki entry point
to perform the request, While some of the bugs were solved, it could still have
performance problems for opening a new process and loading a lot of MediaWiki PHP
objects on it, just to perform a request to see if there are pending jobs and execute
them (it doesn't check if there are jobs to execute). While this may improve speed
on single page requests, because it does not block the execution of the current page,
it has't been thoroughly tested on third party installations. And what is more
important, now there's no way to revert back to the old way of handling those jobs,
as it was done in 1.22 (setting $wgPhpCli = false). This means, in case of major
bugs on the job queue execution due to the new request, there's no way to fix it
other than editing MediaWiki PHP files directly, or completely disable the
on-request job queue handling (some hosts can't set up a cron job for that)

This situation makes it critical to have a safe way to revert to the old job queue
handling, at least until testing that the current implementation doesn't break a lot
of installations.

Bug: 61387
Change-Id: I892a3608228ec0a1c63268fb6180ec679c315980

RELEASE-NOTES-1.23
includes/DefaultSettings.php
includes/Wiki.php

index c231db6..44469cb 100644 (file)
@@ -11,7 +11,9 @@ production.
 === Configuration changes in 1.23 ===
 * When $wgJobRunRate is higher that zero, jobs are now executed via an
   asynchronous HTTP request to a MediaWiki entry point. This may require
-  increasing the number of server worker threads.
+  increasing the number of server worker threads. $wgRunJobsAsync has been
+  added to disable this feature if needed, falling back to executing the job
+  on the same process but making the execution synchronously.
 * $wgDebugLogGroups values may be set to an associative array with a
   'destination' key specifying the log destination. The array may also contain
   a 'sample' key with a positive integer value N indicating that the log group
index a3c22b8..5b2360c 100644 (file)
@@ -6922,6 +6922,14 @@ $wgHTTPConnectTimeout = 5e0;
  */
 $wgJobRunRate = 1;
 
+/**
+ * When $wgJobRunRate > 0, try to run jobs asynchronously, spawning a new process
+ * to handle the job execution, instead of blocking the request until the job
+ * execution finishes.
+ * @since 1.23
+ */
+$wgRunJobsAsync = true;
+
 /**
  * Number of rows to update per job
  */
index 6cf718c..ccc9b8d 100644 (file)
@@ -624,7 +624,7 @@ class MediaWiki {
         * the socket once it's done.
         */
        protected function triggerJobs() {
-               global $wgJobRunRate, $wgServer;
+               global $wgJobRunRate, $wgServer, $wgRunJobsAsync;
 
                if ( $wgJobRunRate <= 0 || wfReadOnly() ) {
                        return;
@@ -644,6 +644,13 @@ class MediaWiki {
                        $n = intval( $wgJobRunRate );
                }
 
+               if ( !$wgRunJobsAsync ) {
+                       // If running jobs asynchronously has been disabled, run the job here
+                       // while the user waits
+                       SpecialRunJobs::executeJobs( $n );
+                       return;
+               }
+
                $query = array( 'title' => 'Special:RunJobs',
                        'tasks' => 'jobs', 'maxjobs' => $n, 'sigexpiry' => time() + 5 );
                $query['signature'] = SpecialRunJobs::getQuerySignature( $query );