From ce2ae144e622f0855684ae30d88741877b448db0 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 17 Jul 2014 12:18:13 -0700 Subject: [PATCH] Removed NextJobDB, which was only used by the old jobs-loop.sh script Change-Id: Ia74386c65011ecca2bd4a0fae6509febd1b2d523 --- RELEASE-NOTES-1.24 | 1 + maintenance/nextJobDB.php | 111 -------------------------------------- 2 files changed, 1 insertion(+), 111 deletions(-) delete mode 100644 maintenance/nextJobDB.php diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24 index 9abbb778a7..dbc1214ecd 100644 --- a/RELEASE-NOTES-1.24 +++ b/RELEASE-NOTES-1.24 @@ -248,6 +248,7 @@ changes to languages because of Bugzilla reports. * Removed Action::execute(). * Removed AjaxAddScript which has been obsolete since ResourceLoader and is unused by any modern extension. +* Removed maintenance/nextJobDB.php; no longer in use. ==== Renamed classes ==== * CLDRPluralRuleConverter_Expression to CLDRPluralRuleConverterExpression diff --git a/maintenance/nextJobDB.php b/maintenance/nextJobDB.php deleted file mode 100644 index d17236338c..0000000000 --- a/maintenance/nextJobDB.php +++ /dev/null @@ -1,111 +0,0 @@ -mDescription = "Pick a database that has pending jobs"; - $this->addOption( 'type', "Search by job type", false, true ); - $this->addOption( 'types', "Space separated list of job types to search for", false, true ); - } - - public function execute() { - global $wgJobTypesExcludedFromDefaultQueue; - - // job type required/picked - if ( $this->hasOption( 'types' ) ) { - $types = explode( ' ', $this->getOption( 'types' ) ); - } elseif ( $this->hasOption( 'type' ) ) { - $types = array( $this->getOption( 'type' ) ); - } else { - $types = false; - } - - // Handle any required periodic queue maintenance - $this->executeReadyPeriodicTasks(); - - // Get all the queues with jobs in them - $pendingDBs = JobQueueAggregator::singleton()->getAllReadyWikiQueues(); - if ( !count( $pendingDBs ) ) { - return; // no DBs with jobs or cache is both empty and locked - } - - $candidates = array(); // list of (type, db) - // Flatten the tree of candidates into a flat list so that a random - // item can be selected, weighing each queue (type/db tuple) equally. - foreach ( $pendingDBs as $type => $dbs ) { - if ( - ( is_array( $types ) && in_array( $type, $types ) ) || - ( $types === false && !in_array( $type, $wgJobTypesExcludedFromDefaultQueue ) ) - ) { - foreach ( $dbs as $db ) { - $candidates[] = array( $type, $db ); - } - } - } - if ( !count( $candidates ) ) { - return; // no jobs for this type - } - - list( $type, $db ) = $candidates[mt_rand( 0, count( $candidates ) - 1 )]; - - if ( $this->hasOption( 'types' ) ) { - $this->output( $db . " " . $type . "\n" ); - } else { - $this->output( $db . "\n" ); - } - } - - /** - * Do all ready periodic jobs for all databases every 5 minutes (and .1% of the time) - * @return int - */ - private function executeReadyPeriodicTasks() { - global $wgLocalDatabases, $wgMemc; - - $count = 0; - $memcKey = 'jobqueue:periodic:lasttime'; - $timestamp = (int)$wgMemc->get( $memcKey ); // UNIX timestamp or 0 - if ( ( time() - $timestamp ) > 300 || mt_rand( 0, 999 ) == 0 ) { // 5 minutes - if ( $wgMemc->add( "$memcKey:rebuild", 1, 1800 ) ) { // lock - foreach ( $wgLocalDatabases as $db ) { - $count += JobQueueGroup::singleton( $db )->executeReadyPeriodicTasks(); - } - $wgMemc->set( $memcKey, time() ); - $wgMemc->delete( "$memcKey:rebuild" ); // unlock - } - } - - return $count; - } -} - -$maintClass = "NextJobDb"; -require_once RUN_MAINTENANCE_IF_MAIN; -- 2.20.1