Made runJobs.php wait for slave lag.
authorAaron Schulz <aschulz@wikimedia.org>
Mon, 25 Feb 2013 17:55:32 +0000 (09:55 -0800)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 6 Mar 2013 03:59:33 +0000 (03:59 +0000)
* Relying on waitForBackups() alone will not work with non DB queues.

Change-Id: I2124c5cd11a70d183cfde00ad21d6642a3a0ee9e

maintenance/runJobs.php

index f9557ce..714bb84 100644 (file)
@@ -82,6 +82,7 @@ class RunJobs extends Maintenance {
                        $this->runJobsLog( "Executed $count periodic queue task(s)." );
                }
 
+               $lastTime = time();
                do {
                        $job = ( $type === false )
                                ? $group->pop( JobQueueGroup::TYPE_DEFAULT, JobQueueGroup::USE_CACHE )
@@ -118,8 +119,13 @@ class RunJobs extends Maintenance {
                                        break;
                                }
 
-                               // Don't let any slaves/backups fall behind...
+                               // Don't let any queue slaves/backups fall behind
                                $group->get( $job->getType() )->waitForBackups();
+                               // Don't let any of the main DB slaves get backed up
+                               $timePassed = time() - $lastTime;
+                               if ( $timePassed >= 5 || $timePassed < 0 ) {
+                                       wfWaitForSlaves();
+                               }
                        }
                } while ( $job ); // stop when there are no jobs
        }