MediaWiki  master
JobRunner.php
Go to the documentation of this file.
1 <?php
24 use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
28 use Psr\Log\LoggerAwareInterface;
29 use Psr\Log\LoggerInterface;
33 use Wikimedia\ScopedCallback;
34 
41 class JobRunner implements LoggerAwareInterface {
42 
46  public const CONSTRUCTOR_OPTIONS = [
47  'JobBackoffThrottling',
48  'JobClasses',
49  'JobSerialCommitThreshold',
50  'MaxJobDBWriteDuration',
51  'TrxProfilerLimits'
52  ];
53 
55  private $options;
56 
58  private $lbFactory;
59 
61  private $jobQueueGroup;
62 
64  private $readOnlyMode;
65 
67  private $linkCache;
68 
70  private $stats;
71 
73  private $debug;
74 
76  private $logger;
77 
79  private const MAX_ALLOWED_LAG = 3;
81  private const SYNC_TIMEOUT = self::MAX_ALLOWED_LAG;
83  private const LAG_CHECK_PERIOD = 1.0;
85  private const ERROR_BACKOFF_TTL = 1;
87  private const READONLY_BACKOFF_TTL = 30;
88 
92  public function setDebugHandler( $debug ) {
93  $this->debug = $debug;
94  }
95 
101  public function setLogger( LoggerInterface $logger ) {
102  wfDeprecated( __METHOD__, '1.35' );
103  $this->logger = $logger;
104  }
105 
117  public function __construct(
118  $serviceOptions = null,
119  ILBFactory $lbFactory = null,
122  LinkCache $linkCache = null,
123  StatsdDataFactoryInterface $statsdDataFactory = null,
124  LoggerInterface $logger = null
125  ) {
126  if ( !$serviceOptions || $serviceOptions instanceof LoggerInterface ) {
127  // TODO: wfDeprecated( __METHOD__ . 'called directly. Use MediaWikiServices instead', '1.35' );
128  $logger = $serviceOptions;
129  $serviceOptions = new ServiceOptions(
130  static::CONSTRUCTOR_OPTIONS,
131  MediaWikiServices::getInstance()->getMainConfig()
132  );
133  }
134 
135  $this->options = $serviceOptions;
136  $this->lbFactory = $lbFactory ?? MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
137  $this->jobQueueGroup = $jobQueueGroup ?? JobQueueGroup::singleton();
138  $this->readOnlyMode = $readOnlyMode ?: MediaWikiServices::getInstance()->getReadOnlyMode();
139  $this->linkCache = $linkCache ?? MediaWikiServices::getInstance()->getLinkCache();
140  $this->stats = $statsdDataFactory ?? MediaWikiServices::getInstance()->getStatsdDataFactory();
141  $this->logger = $logger ?? LoggerFactory::getInstance( 'runJobs' );
142  }
143 
169  public function run( array $options ) {
170  $type = $options['type'] ?? false;
171  $maxJobs = $options['maxJobs'] ?? false;
172  $maxTime = $options['maxTime'] ?? false;
173  $throttle = $options['throttle'] ?? true;
174 
175  $jobClasses = $this->options->get( 'JobClasses' );
176  $profilerLimits = $this->options->get( 'TrxProfilerLimits' );
177 
178  $response = [ 'jobs' => [], 'reached' => 'none-ready' ];
179 
180  if ( $type !== false && !isset( $jobClasses[$type] ) ) {
181  // Invalid job type specified
182  $response['reached'] = 'none-possible';
183  return $response;
184  }
185 
186  if ( $this->readOnlyMode->isReadOnly() ) {
187  // Any jobs popped off the queue might fail to run and thus might end up lost
188  $response['reached'] = 'read-only';
189  return $response;
190  }
191 
192  list( , $maxLag ) = $this->lbFactory->getMainLB()->getMaxLag();
193  if ( $maxLag >= self::MAX_ALLOWED_LAG ) {
194  // DB lag is already too high; caller can immediately try other wikis if applicable
195  $response['reached'] = 'replica-lag-limit';
196  return $response;
197  }
198 
199  // Narrow DB query expectations for this HTTP request
200  $this->lbFactory->getTransactionProfiler()
201  ->setExpectations( $profilerLimits['JobRunner'], __METHOD__ );
202 
203  // Error out if an explicit DB transaction round is somehow active
204  if ( $this->lbFactory->hasTransactionRound() ) {
205  throw new LogicException( __METHOD__ . ' called with an active transaction round.' );
206  }
207 
208  // Some jobs types should not run until a certain timestamp
209  $backoffs = []; // map of (type => UNIX expiry)
210  $backoffDeltas = []; // map of (type => seconds)
211  $wait = 'wait'; // block to read backoffs the first time
212 
213  $loopStartTime = microtime( true );
214  $jobsPopped = 0;
215  $timeMsTotal = 0;
216  $lastSyncTime = 1; // initialize "last sync check timestamp" to "ages ago"
217  // Keep popping and running jobs until there are no more...
218  do {
219  // Sync the persistent backoffs with concurrent runners
220  $backoffs = $this->syncBackoffDeltas( $backoffs, $backoffDeltas, $wait );
221  $blacklist = $throttle ? array_keys( $backoffs ) : [];
222  $wait = 'nowait'; // less important now
223 
224  if ( $type === false ) {
225  // Treat the default job type queues as a single queue and pop off a job
226  $job = $this->jobQueueGroup
228  } else {
229  // Pop off a job from the specified job type queue unless the execution of
230  // that type of job is currently rate-limited by the back-off blacklist
231  $job = in_array( $type, $blacklist ) ? false : $this->jobQueueGroup->pop( $type );
232  }
233 
234  if ( $job ) {
235  ++$jobsPopped;
236  $jType = $job->getType();
237 
238  // Back off of certain jobs for a while (for throttling and for errors)
239  $ttw = $this->getBackoffTimeToWait( $job );
240  if ( $ttw > 0 ) {
241  // Always add the delta for other runners in case the time running the
242  // job negated the backoff for each individually but not collectively.
243  $backoffDeltas[$jType] = ( $backoffDeltas[$jType] ?? 0 ) + $ttw;
244  $backoffs = $this->syncBackoffDeltas( $backoffs, $backoffDeltas, $wait );
245  }
246 
247  $info = $this->executeJob( $job );
248 
249  // Mark completed or "one shot only" jobs as resolved
250  if ( $info['status'] !== false || !$job->allowRetries() ) {
251  $this->jobQueueGroup->ack( $job );
252  }
253 
254  // Back off of certain jobs for a while (for throttling and for errors)
255  if ( $info['status'] === false && mt_rand( 0, 49 ) == 0 ) {
256  $ttw = max( $ttw, $this->getErrorBackoffTTL( $info['caught'] ) );
257  $backoffDeltas[$jType] = isset( $backoffDeltas[$jType] )
258  ? $backoffDeltas[$jType] + $ttw
259  : $ttw;
260  }
261 
262  $response['jobs'][] = [
263  'type' => $jType,
264  'status' => ( $info['status'] === false ) ? 'failed' : 'ok',
265  'error' => $info['error'],
266  'time' => $info['timeMs']
267  ];
268  $timeMsTotal += $info['timeMs'];
269 
270  // Break out if we hit the job count or wall time limits
271  if ( $maxJobs && $jobsPopped >= $maxJobs ) {
272  $response['reached'] = 'job-limit';
273  break;
274  } elseif ( $maxTime && ( microtime( true ) - $loopStartTime ) > $maxTime ) {
275  $response['reached'] = 'time-limit';
276  break;
277  }
278 
279  // Don't let any of the main DB replica DBs get backed up.
280  // This only waits for so long before exiting and letting
281  // other wikis in the farm (on different masters) get a chance.
282  $timePassed = microtime( true ) - $lastSyncTime;
283  if ( $timePassed >= self::LAG_CHECK_PERIOD || $timePassed < 0 ) {
284  $opts = [ 'ifWritesSince' => $lastSyncTime, 'timeout' => self::SYNC_TIMEOUT ];
285  if ( !$this->lbFactory->waitForReplication( $opts ) ) {
286  $response['reached'] = 'replica-lag-limit';
287  break;
288  }
289  $lastSyncTime = microtime( true );
290  }
291 
292  // Abort if nearing OOM to avoid erroring out in the middle of a job
293  if ( !$this->checkMemoryOK() ) {
294  $response['reached'] = 'memory-limit';
295  break;
296  }
297  }
298  } while ( $job );
299 
300  // Sync the persistent backoffs for the next runJobs.php pass
301  if ( $backoffDeltas ) {
302  $this->syncBackoffDeltas( $backoffs, $backoffDeltas, 'wait' );
303  }
304 
305  $response['backoffs'] = $backoffs;
306  $response['elapsed'] = $timeMsTotal;
307 
308  return $response;
309  }
310 
329  public function executeJob( RunnableJob $job ) {
330  $oldRequestId = WebRequest::getRequestId();
331  // Temporarily inherit the original ID of the web request that spawned this job
332  WebRequest::overrideRequestId( $job->getRequestId() );
333  // Use an appropriate timeout to balance lag avoidance and job progress
334  $oldTimeout = $this->lbFactory->setDefaultReplicationWaitTimeout( self::SYNC_TIMEOUT );
335  try {
336  return $this->doExecuteJob( $job );
337  } finally {
338  $this->lbFactory->setDefaultReplicationWaitTimeout( $oldTimeout );
339  WebRequest::overrideRequestId( $oldRequestId );
340  }
341  }
342 
351  private function doExecuteJob( RunnableJob $job ) {
352  $jType = $job->getType();
353  $msg = $job->toString() . " STARTING";
354  $this->logger->debug( $msg, [ 'job_type' => $job->getType() ] );
355  $this->debugCallback( $msg );
356 
357  // Clear out title cache data from prior snapshots
358  // (e.g. from before JobRunner was invoked in this process)
359  $this->linkCache->clear();
360 
361  // Run the job...
362  $caught = [];
363  $rssStart = $this->getMaxRssKb();
364  $jobStartTime = microtime( true );
365  try {
366  $fnameTrxOwner = get_class( $job ) . '::run'; // give run() outer scope
367  // Flush any pending changes left over from an implicit transaction round
368  if ( $job->hasExecutionFlag( $job::JOB_NO_EXPLICIT_TRX_ROUND ) ) {
369  $this->lbFactory->commitMasterChanges( $fnameTrxOwner ); // new implicit round
370  } else {
371  $this->lbFactory->beginMasterChanges( $fnameTrxOwner ); // new explicit round
372  }
373  // Clear any stale REPEATABLE-READ snapshots from replica DB connections
374  $this->lbFactory->flushReplicaSnapshots( $fnameTrxOwner );
375  $status = $job->run();
376  $error = $job->getLastError();
377  // Commit all pending changes from this job
378  $this->commitMasterChanges( $job, $fnameTrxOwner );
379  // Run any deferred update tasks; doUpdates() manages transactions itself
381  } catch ( Throwable $e ) {
383  $status = false;
384  $error = get_class( $e ) . ': ' . $e->getMessage();
385  $caught[] = get_class( $e );
386  }
387  // Always attempt to call teardown(), even if Job throws exception
388  try {
389  $job->tearDown( $status );
390  } catch ( Throwable $e ) {
392  }
393 
394  $timeMs = intval( ( microtime( true ) - $jobStartTime ) * 1000 );
395  $rssEnd = $this->getMaxRssKb();
396 
397  // Record how long jobs wait before getting popped
398  $readyTs = $job->getReadyTimestamp();
399  if ( $readyTs ) {
400  $pickupDelay = max( 0, $jobStartTime - $readyTs );
401  $this->stats->timing( 'jobqueue.pickup_delay.all', 1000 * $pickupDelay );
402  $this->stats->timing( "jobqueue.pickup_delay.$jType", 1000 * $pickupDelay );
403  }
404  // Record root job age for jobs being run
405  $rootTimestamp = $job->getRootJobParams()['rootJobTimestamp'];
406  if ( $rootTimestamp ) {
407  $age = max( 0, $jobStartTime - wfTimestamp( TS_UNIX, $rootTimestamp ) );
408  $this->stats->timing( "jobqueue.pickup_root_age.$jType", 1000 * $age );
409  }
410  // Track the execution time for jobs
411  $this->stats->timing( "jobqueue.run.$jType", $timeMs );
412  // Track RSS increases for jobs (in case of memory leaks)
413  if ( $rssStart && $rssEnd ) {
414  $this->stats->updateCount( "jobqueue.rss_delta.$jType", $rssEnd - $rssStart );
415  }
416 
417  if ( $status === false ) {
418  $msg = $job->toString() . " t={job_duration} error={job_error}";
419  $this->logger->error( $msg, [
420  'job_type' => $job->getType(),
421  'job_duration' => $timeMs,
422  'job_error' => $error,
423  ] );
424 
425  $msg = $job->toString() . " t=$timeMs error={$error}";
426  $this->debugCallback( $msg );
427  } else {
428  $msg = $job->toString() . " t={job_duration} good";
429  $this->logger->info( $msg, [
430  'job_type' => $job->getType(),
431  'job_duration' => $timeMs,
432  ] );
433 
434  $msg = $job->toString() . " t=$timeMs good";
435  $this->debugCallback( $msg );
436  }
437 
438  return [
439  'status' => $status,
440  'error' => $error,
441  'caught' => $caught,
442  'timeMs' => $timeMs
443  ];
444  }
445 
450  private function getErrorBackoffTTL( array $caught ) {
451  return in_array( DBReadOnlyError::class, $caught )
452  ? self::READONLY_BACKOFF_TTL
453  : self::ERROR_BACKOFF_TTL;
454  }
455 
459  private function getMaxRssKb() {
460  $info = getrusage( 0 /* RUSAGE_SELF */ );
461  // see https://linux.die.net/man/2/getrusage
462  return isset( $info['ru_maxrss'] ) ? (int)$info['ru_maxrss'] : null;
463  }
464 
470  private function getBackoffTimeToWait( RunnableJob $job ) {
471  $throttling = $this->options->get( 'JobBackoffThrottling' );
472 
473  if ( !isset( $throttling[$job->getType()] ) || $job instanceof DuplicateJob ) {
474  return 0; // not throttled
475  }
476 
477  $itemsPerSecond = $throttling[$job->getType()];
478  if ( $itemsPerSecond <= 0 ) {
479  return 0; // not throttled
480  }
481 
482  $seconds = 0;
483  if ( $job->workItemCount() > 0 ) {
484  $exactSeconds = $job->workItemCount() / $itemsPerSecond;
485  // use randomized rounding
486  $seconds = floor( $exactSeconds );
487  $remainder = $exactSeconds - $seconds;
488  $seconds += ( mt_rand() / mt_getrandmax() < $remainder ) ? 1 : 0;
489  }
490 
491  return (int)$seconds;
492  }
493 
502  private function loadBackoffs( array $backoffs, $mode = 'wait' ) {
503  $file = wfTempDir() . '/mw-runJobs-backoffs.json';
504  if ( is_file( $file ) ) {
505  $noblock = ( $mode === 'nowait' ) ? LOCK_NB : 0;
506  $handle = fopen( $file, 'rb' );
507  if ( !flock( $handle, LOCK_SH | $noblock ) ) {
508  fclose( $handle );
509  return $backoffs; // don't wait on lock
510  }
511  $content = stream_get_contents( $handle );
512  flock( $handle, LOCK_UN );
513  fclose( $handle );
514  $ctime = microtime( true );
515  $cBackoffs = json_decode( $content, true ) ?: [];
516  foreach ( $cBackoffs as $type => $timestamp ) {
517  if ( $timestamp < $ctime ) {
518  unset( $cBackoffs[$type] );
519  }
520  }
521  } else {
522  $cBackoffs = [];
523  }
524 
525  return $cBackoffs;
526  }
527 
539  private function syncBackoffDeltas( array $backoffs, array &$deltas, $mode = 'wait' ) {
540  if ( !$deltas ) {
541  return $this->loadBackoffs( $backoffs, $mode );
542  }
543 
544  $noblock = ( $mode === 'nowait' ) ? LOCK_NB : 0;
545  $file = wfTempDir() . '/mw-runJobs-backoffs.json';
546  $handle = fopen( $file, 'wb+' );
547  if ( !flock( $handle, LOCK_EX | $noblock ) ) {
548  fclose( $handle );
549  return $backoffs; // don't wait on lock
550  }
551  $ctime = microtime( true );
552  $content = stream_get_contents( $handle );
553  $cBackoffs = json_decode( $content, true ) ?: [];
554  foreach ( $deltas as $type => $seconds ) {
555  $cBackoffs[$type] = isset( $cBackoffs[$type] ) && $cBackoffs[$type] >= $ctime
556  ? $cBackoffs[$type] + $seconds
557  : $ctime + $seconds;
558  }
559  foreach ( $cBackoffs as $type => $timestamp ) {
560  if ( $timestamp < $ctime ) {
561  unset( $cBackoffs[$type] );
562  }
563  }
564  ftruncate( $handle, 0 );
565  fwrite( $handle, json_encode( $cBackoffs ) );
566  flock( $handle, LOCK_UN );
567  fclose( $handle );
568 
569  $deltas = [];
570 
571  return $cBackoffs;
572  }
573 
579  private function checkMemoryOK() {
580  static $maxBytes = null;
581  if ( $maxBytes === null ) {
582  $m = [];
583  if ( preg_match( '!^(\d+)(k|m|g|)$!i', ini_get( 'memory_limit' ), $m ) ) {
584  list( , $num, $unit ) = $m;
585  $conv = [ 'g' => 1073741824, 'm' => 1048576, 'k' => 1024, '' => 1 ];
586  $maxBytes = $num * $conv[strtolower( $unit )];
587  } else {
588  $maxBytes = 0;
589  }
590  }
591  $usedBytes = memory_get_usage();
592  if ( $maxBytes && $usedBytes >= 0.95 * $maxBytes ) {
593  $msg = "Detected excessive memory usage ({used_bytes}/{max_bytes}).";
594  $this->logger->error( $msg, [
595  'used_bytes' => $usedBytes,
596  'max_bytes' => $maxBytes,
597  ] );
598 
599  $msg = "Detected excessive memory usage ($usedBytes/$maxBytes).";
600  $this->debugCallback( $msg );
601 
602  return false;
603  }
604 
605  return true;
606  }
607 
612  private function debugCallback( $msg ) {
613  if ( $this->debug ) {
614  call_user_func_array( $this->debug, [ wfTimestamp( TS_DB ) . " $msg\n" ] );
615  }
616  }
617 
628  private function commitMasterChanges( RunnableJob $job, $fnameTrxOwner ) {
629  $syncThreshold = $this->options->get( 'JobSerialCommitThreshold' );
630 
631  $time = false;
632  $lb = $this->lbFactory->getMainLB();
633  if ( $syncThreshold !== false && $lb->hasStreamingReplicaServers() ) {
634  // Generally, there is one master connection to the local DB
635  $dbwSerial = $lb->getAnyOpenConnection( $lb->getWriterIndex() );
636  // We need natively blocking fast locks
637  if ( $dbwSerial && $dbwSerial->namedLocksEnqueue() ) {
638  $time = $dbwSerial->pendingWriteQueryDuration( $dbwSerial::ESTIMATE_DB_APPLY );
639  if ( $time < $syncThreshold ) {
640  $dbwSerial = false;
641  }
642  } else {
643  $dbwSerial = false;
644  }
645  } else {
646  // There are no replica DBs or writes are all to foreign DB (we don't handle that)
647  $dbwSerial = false;
648  }
649 
650  if ( !$dbwSerial ) {
651  $this->lbFactory->commitMasterChanges(
652  $fnameTrxOwner,
653  // Abort if any transaction was too big
654  [ 'maxWriteDuration' => $this->options->get( 'MaxJobDBWriteDuration' ) ]
655  );
656 
657  return;
658  }
659 
660  $ms = intval( 1000 * $time );
661 
662  $msg = $job->toString() . " COMMIT ENQUEUED [{job_commit_write_ms}ms of writes]";
663  $this->logger->info( $msg, [
664  'job_type' => $job->getType(),
665  'job_commit_write_ms' => $ms,
666  ] );
667 
668  $msg = $job->toString() . " COMMIT ENQUEUED [{$ms}ms of writes]";
669  $this->debugCallback( $msg );
670 
671  // Wait for an exclusive lock to commit
672  if ( !$dbwSerial->lock( 'jobrunner-serial-commit', $fnameTrxOwner, 30 ) ) {
673  // This will trigger a rollback in the main loop
674  throw new DBError( $dbwSerial, "Timed out waiting on commit queue." );
675  }
676  $unlocker = new ScopedCallback( function () use ( $dbwSerial, $fnameTrxOwner ) {
677  $dbwSerial->unlock( 'jobrunner-serial-commit', $fnameTrxOwner );
678  } );
679 
680  // Wait for the replica DBs to catch up
681  $pos = $lb->getMasterPos();
682  if ( $pos ) {
683  $lb->waitForAll( $pos );
684  }
685 
686  // Actually commit the DB master changes
687  $this->lbFactory->commitMasterChanges(
688  $fnameTrxOwner,
689  // Abort if any transaction was too big
690  [ 'maxWriteDuration' => $this->options->get( 'MaxJobDBWriteDuration' ) ]
691  );
692  ScopedCallback::consume( $unlocker );
693  }
694 }
JobQueueGroup\USE_CACHE
const USE_CACHE
Definition: JobQueueGroup.php:50
JobRunner\commitMasterChanges
commitMasterChanges(RunnableJob $job, $fnameTrxOwner)
Issue a commit on all masters who are currently in a transaction and have made changes to the databas...
Definition: JobRunner.php:628
LinkCache
Cache for article titles (prefixed DB keys) and ids linked from one source.
Definition: LinkCache.php:35
JobRunner\$logger
LoggerInterface $logger
Definition: JobRunner.php:76
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:163
JobQueueGroup\TYPE_DEFAULT
const TYPE_DEFAULT
Definition: JobQueueGroup.php:47
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1815
ReadOnlyMode
A service class for fetching the wiki's current read-only mode.
Definition: ReadOnlyMode.php:11
JobRunner\$options
ServiceOptions $options
Definition: JobRunner.php:55
RunnableJob
Job that has a run() method and metadata accessors for JobQueue::pop() and JobQueue::ack()
Definition: RunnableJob.php:37
$file
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Definition: router.php:42
JobRunner\getBackoffTimeToWait
getBackoffTimeToWait(RunnableJob $job)
Definition: JobRunner.php:470
Wikimedia\Rdbms\DBError
Database error base class @newable Stable to extend.
Definition: DBError.php:32
MWExceptionHandler\logException
static logException(Throwable $e, $catcher=self::CAUGHT_BY_OTHER, $extraData=[])
Log a throwable to the exception log (if enabled).
Definition: MWExceptionHandler.php:668
JobRunner\syncBackoffDeltas
syncBackoffDeltas(array $backoffs, array &$deltas, $mode='wait')
Merge the current backoff expiries from persistent storage.
Definition: JobRunner.php:539
JobRunner\executeJob
executeJob(RunnableJob $job)
Run a specific job in a manner appropriate for mass use by job dispatchers.
Definition: JobRunner.php:329
JobRunner\$lbFactory
ILBFactory $lbFactory
Definition: JobRunner.php:58
JobRunner\setLogger
setLogger(LoggerInterface $logger)
Definition: JobRunner.php:101
MediaWiki\Config\ServiceOptions
A class for passing options to services.
Definition: ServiceOptions.php:27
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
Definition: GlobalFunctions.php:1027
MediaWiki\Logger\LoggerFactory
PSR-3 logger instance factory.
Definition: LoggerFactory.php:45
JobRunner\__construct
__construct( $serviceOptions=null, ILBFactory $lbFactory=null, JobQueueGroup $jobQueueGroup=null, ReadOnlyMode $readOnlyMode=null, LinkCache $linkCache=null, StatsdDataFactoryInterface $statsdDataFactory=null, LoggerInterface $logger=null)
Calling this directly is deprecated.
Definition: JobRunner.php:117
JobRunner\debugCallback
debugCallback( $msg)
Log the job message.
Definition: JobRunner.php:612
JobRunner\run
run(array $options)
Run jobs of the specified number/type for the specified time.
Definition: JobRunner.php:169
JobRunner\loadBackoffs
loadBackoffs(array $backoffs, $mode='wait')
Get the previous backoff expiries from persistent storage On I/O or lock acquisition failure this ret...
Definition: JobRunner.php:502
DuplicateJob
No-op job that does nothing.
Definition: DuplicateJob.php:29
Wikimedia\Rdbms\DBReadOnlyError
@newable
Definition: DBReadOnlyError.php:28
JobRunner\CONSTRUCTOR_OPTIONS
const CONSTRUCTOR_OPTIONS
Definition: JobRunner.php:46
JobRunner\setDebugHandler
setDebugHandler( $debug)
Definition: JobRunner.php:92
JobRunner\$readOnlyMode
ReadOnlyMode $readOnlyMode
Definition: JobRunner.php:64
$content
$content
Definition: router.php:76
JobRunner\$debug
callable null $debug
Debug output handler.
Definition: JobRunner.php:73
DeferredUpdates\doUpdates
static doUpdates( $mode='run', $stage=self::ALL)
Consume the list of deferred updates and execute them.
Definition: DeferredUpdates.php:171
JobRunner\$linkCache
LinkCache $linkCache
Definition: JobRunner.php:67
JobRunner\getMaxRssKb
getMaxRssKb()
Definition: JobRunner.php:459
wfTempDir
wfTempDir()
Tries to get the system directory for temporary files.
Definition: GlobalFunctions.php:1878
MWExceptionHandler\rollbackMasterChangesAndLog
static rollbackMasterChangesAndLog(Throwable $e, $catcher=self::CAUGHT_BY_OTHER)
Roll back any open database transactions and log the stack trace of the throwable.
Definition: MWExceptionHandler.php:125
JobQueueGroup\singleton
static singleton( $domain=false)
Definition: JobQueueGroup.php:70
$job
if(count( $args)< 1) $job
Definition: recompressTracked.php:50
JobRunner\$jobQueueGroup
JobQueueGroup $jobQueueGroup
Definition: JobRunner.php:61
WebRequest\getRequestId
static getRequestId()
Get the unique request ID.
Definition: WebRequest.php:327
JobRunner\doExecuteJob
doExecuteJob(RunnableJob $job)
Definition: JobRunner.php:351
JobRunner\getErrorBackoffTTL
getErrorBackoffTTL(array $caught)
Definition: JobRunner.php:450
MediaWiki\Config\ServiceOptions\get
get( $key)
Definition: ServiceOptions.php:88
JobRunner
Job queue runner utility methods.
Definition: JobRunner.php:41
JobRunner\$stats
StatsdDataFactoryInterface $stats
Definition: JobRunner.php:70
WebRequest\overrideRequestId
static overrideRequestId( $id)
Override the unique request ID.
Definition: WebRequest.php:351
Wikimedia\Rdbms\ILBFactory
An interface for generating database load balancers.
Definition: ILBFactory.php:33
JobQueueGroup
Class to handle enqueueing of background jobs.
Definition: JobQueueGroup.php:30
JobRunner\checkMemoryOK
checkMemoryOK()
Make sure that this script is not too close to the memory usage limit.
Definition: JobRunner.php:579
$type
$type
Definition: testCompression.php:52