Made nextJobDB.php respect $wgJobTypesExcludedFromDefaultQueue.
Change-Id: I22de34fc7be7b701180511fad3c16154ffdf638b
This commit is contained in:
parent
d82616449f
commit
7875479757
1 changed files with 22 additions and 34 deletions
|
|
@ -45,7 +45,7 @@ class nextJobDB extends Maintenance {
|
||||||
} elseif ( $this->hasOption( 'type' ) ) {
|
} elseif ( $this->hasOption( 'type' ) ) {
|
||||||
$types = array( $this->getOption( 'type' ) );
|
$types = array( $this->getOption( 'type' ) );
|
||||||
} else {
|
} else {
|
||||||
$types = false;
|
$types = JobQueueGroup::singleton()->getDefaultQueueTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
$memcKey = 'jobqueue:dbs:v3';
|
$memcKey = 'jobqueue:dbs:v3';
|
||||||
|
|
@ -82,24 +82,22 @@ class nextJobDB extends Maintenance {
|
||||||
do {
|
do {
|
||||||
$again = false;
|
$again = false;
|
||||||
|
|
||||||
if ( $types === false ) {
|
$candidates = array(); // list of (type, db)
|
||||||
$candidates = call_user_func_array( 'array_merge', $pendingDBs );
|
// Flatten the tree of candidates into a flat list so that a random
|
||||||
} else {
|
// item can be selected, weighing each queue (type/db tuple) equally.
|
||||||
$candidates = array();
|
foreach ( $pendingDBs as $type => $dbs ) {
|
||||||
$possTypes = array_intersect( $types, array_keys( $pendingDBs ) );
|
if ( in_array( $type, $types ) ) {
|
||||||
if ( $possTypes ) {
|
foreach ( $dbs as $db ) {
|
||||||
$possTypes = array_values( $possTypes );
|
$candidates[] = array( $type, $db );
|
||||||
$type = $possTypes[ mt_rand( 0, count( $possTypes ) - 1 ) ];
|
}
|
||||||
$candidates = $pendingDBs[$type];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !$candidates ) {
|
if ( !count( $candidates ) ) {
|
||||||
return; // no jobs for this type
|
return; // no jobs for this type
|
||||||
}
|
}
|
||||||
|
|
||||||
$candidates = array_values( $candidates );
|
list( $type, $db ) = $candidates[ mt_rand( 0, count( $candidates ) - 1 ) ];
|
||||||
$db = $candidates[ mt_rand( 0, count( $candidates ) - 1 ) ];
|
if ( !$this->checkJob( $type, $db ) ) { // queue is actually empty?
|
||||||
if ( !$this->checkJob( $type, $db ) ) {
|
|
||||||
$pendingDBs = $this->delistDB( $pendingDBs, $db, $type );
|
$pendingDBs = $this->delistDB( $pendingDBs, $db, $type );
|
||||||
// Update the cache to remove the outdated information.
|
// Update the cache to remove the outdated information.
|
||||||
// Make sure that this does not race (especially with full rebuilds).
|
// Make sure that this does not race (especially with full rebuilds).
|
||||||
|
|
@ -125,16 +123,16 @@ class nextJobDB extends Maintenance {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a type/DB entry from the list of queues with jobs
|
||||||
|
*
|
||||||
|
* @param $pendingDBs array
|
||||||
|
* @param $db string
|
||||||
|
* @param $type string
|
||||||
|
* @return Array
|
||||||
|
*/
|
||||||
private function delistDB( array $pendingDBs, $db, $type ) {
|
private function delistDB( array $pendingDBs, $db, $type ) {
|
||||||
if ( $type === false ) {
|
$pendingDBs[$type] = array_diff( $pendingDBs[$type], array( $db ) );
|
||||||
// There are no jobs available in the current database
|
|
||||||
foreach ( $pendingDBs as $type2 => $dbs ) {
|
|
||||||
$pendingDBs[$type2] = array_diff( $pendingDBs[$type2], array( $db ) );
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// There are no jobs of this type available in the current database
|
|
||||||
$pendingDBs[$type] = array_diff( $pendingDBs[$type], array( $db ) );
|
|
||||||
}
|
|
||||||
return $pendingDBs;
|
return $pendingDBs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -146,17 +144,7 @@ class nextJobDB extends Maintenance {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function checkJob( $type, $dbName ) {
|
private function checkJob( $type, $dbName ) {
|
||||||
$group = JobQueueGroup::singleton( $dbName );
|
return !JobQueueGroup::singleton( $dbName )->get( $type )->isEmpty();
|
||||||
if ( $type === false ) {
|
|
||||||
foreach ( $group->getDefaultQueueTypes() as $type ) {
|
|
||||||
if ( !$group->get( $type )->isEmpty() ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return !$group->get( $type )->isEmpty();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue