Randomize the JobRunner slave lags checks a bit
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 19 Sep 2014 20:28:05 +0000 (13:28 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 24 Sep 2014 01:10:04 +0000 (18:10 -0700)
Change-Id: Iee777426776c12051761d29c90da80cea27619b1

includes/jobqueue/JobRunner.php

index 8ccceda..cfcd466 100644 (file)
@@ -87,8 +87,10 @@ class JobRunner {
                $jobsRun = 0;
                $timeMsTotal = 0;
                $flags = JobQueueGroup::USE_CACHE;
+               $checkPeriod = 5.0; // seconds
+               $checkPhase = mt_rand( 0, 1000 * $checkPeriod ) / 1000; // avoid stampedes
                $startTime = microtime( true ); // time since jobs started running
-               $lastTime = microtime( true ); // time since last slave check
+               $lastTime = microtime( true ) - $checkPhase; // time since last slave check
                do {
                        // Sync the persistent backoffs with concurrent runners
                        $backoffs = $this->syncBackoffDeltas( $backoffs, $backoffDeltas, $wait );