MediaWiki master
MediaWiki\JobQueue\JobQueueDB Class Reference

Database-backed job queue storage. More...

Inherits MediaWiki\JobQueue\JobQueue.

Collaboration diagram for MediaWiki\JobQueue\JobQueueDB:

Public Member Functions

 doBatchPushInternal (IDatabase $dbw, array $jobs, $flags, $method)
 This function should not be called outside of JobQueueDB.
 
 getAllAbandonedJobs ()
 
 getAllAcquiredJobs ()
 
 getAllQueuedJobs ()
 
 getCoalesceLocationInternal ()
 Do not use this function outside of JobQueue/JobQueueGroup.
 
 recycleAndDeleteStaleJobs ()
 Recycle or destroy any jobs that have been claimed for too long.
 
- Public Member Functions inherited from MediaWiki\JobQueue\JobQueue
 ack (RunnableJob $job)
 Acknowledge that a job was completed.
 
 batchPush (array $jobs, $flags=0)
 Push a batch of jobs into the queue.
 
 deduplicateRootJob (IJobSpecification $job)
 Register the "root job" of a given job into the queue for de-duplication.
 
 delayedJobsEnabled ()
 
 delete ()
 Delete all unclaimed and delayed jobs from the queue.
 
 flushCaches ()
 Clear any process and persistent caches.
 
 getAbandonedCount ()
 Get the number of acquired jobs that can no longer be attempted.
 
 getAcquiredCount ()
 Get the number of acquired jobs (these are temporarily out of the queue).
 
 getAllDelayedJobs ()
 Get an iterator to traverse over all delayed jobs in this queue.
 
 getDelayedCount ()
 Get the number of delayed jobs (these are temporarily out of the queue).
 
 getDomain ()
 
 getOrder ()
 
 getReadOnlyReason ()
 
 getSiblingQueueSizes (array $types)
 Check the size of each of the given queues.
 
 getSiblingQueuesWithJobs (array $types)
 Check whether each of the given queues are empty.
 
 getSize ()
 Get the number of available (unacquired, non-delayed) jobs in the queue.
 
 getType ()
 
 isEmpty ()
 Quickly check if the queue has no available (unacquired, non-delayed) jobs.
 
 pop ()
 Pop a job off of the queue.
 
 push ( $jobs, $flags=0)
 Push one or more jobs into the queue.
 
 waitForBackups ()
 Wait for any replica DBs or backup servers to catch up.
 

Static Public Member Functions

static selectFields ()
 Return the list of job fields that should be selected.
 
- Static Public Member Functions inherited from MediaWiki\JobQueue\JobQueue
static factory (array $params)
 Get a job queue object of the specified type.
 

Protected Member Functions

 __construct (array $params)
 Additional parameters include:
 
 claimOldest ( $uuid)
 Reserve a row with a single UPDATE without holding row locks over RTTs...
 
 claimRandom ( $uuid, $rand, $gte)
 Reserve a row with a single UPDATE without holding row locks over RTTs...
 
 doAck (RunnableJob $job)
 
 doBatchPush (array $jobs, $flags)
 
 doDeduplicateRootJob (IJobSpecification $job)
 
 doDelete ()
 
 doFlushCaches ()
 
 doGetAbandonedCount ()
 
 doGetAcquiredCount ()
 
 doGetSiblingQueueSizes (array $types)
 
 doGetSiblingQueuesWithJobs (array $types)
 
 doGetSize ()
 
 doIsEmpty ()
 
 doPop ()
 
 doWaitForBackups ()
 
 getDB ( $index)
 
 getDBException (DBError $e)
 
 getJobIterator (array $conds)
 
 getPrimaryDB ()
 
 getReplicaDB ()
 
 insertFields (IJobSpecification $job, IReadableDatabase $db)
 
 jobFromRow ( $row)
 
 optimalOrder ()
 Get the default queue order to use if configuration does not specify one.
 
 supportedOrders ()
 Get the allowed queue orders for configuration validation.
 
- Protected Member Functions inherited from MediaWiki\JobQueue\JobQueue
 assertNotReadOnly ()
 
 doGetDelayedCount ()
 
 doIsRootJobOldDuplicate (IJobSpecification $job)
 
 factoryJob ( $command, $params)
 
 getRootJobCacheKey ( $signature, $type)
 
 incrStats ( $event, $type, $delta=1)
 Call StatsFactory::incrementBy() for the queue overall and for the queue type.
 
 isRootJobOldDuplicate (IJobSpecification $job)
 Check if the "root" job of a given job has been superseded by a newer one.
 
 supportsDelayedJobs ()
 Find out if delayed jobs are supported for configuration validation.
 
 supportsTypeAgnostic ()
 Subclasses should set this to true if they support type agnostic queues.
 

Static Protected Member Functions

static makeBlob ( $params)
 

Protected Attributes

string null $cluster
 Name of an external DB cluster or null for the local DB cluster.
 
IMaintainableDatabase DBError null $conn
 
array null $server
 Server configuration array.
 
- Protected Attributes inherited from MediaWiki\JobQueue\JobQueue
int $claimTTL
 Time to live in seconds.
 
string $domain
 DB domain ID.
 
GlobalIdGenerator $idGenerator
 
int $maxTries
 Maximum number of times to try a job.
 
string $order
 Job priority for pop()
 
string false $readOnlyReason
 Read only rationale (or false if r/w)
 
StatsFactory $stats
 
string $type
 Job type.
 
bool $typeAgnostic
 
WANObjectCache $wanCache
 
const QOS_ATOMIC = 1
 
const ROOTJOB_TTL = 28 * 24 * 3600
 

Detailed Description

Database-backed job queue storage.

Since
1.21

Definition at line 46 of file JobQueueDB.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\JobQueue\JobQueueDB::__construct ( array $params)
protected

Additional parameters include:

  • server : Server configuration array for Database::factory. Overrides "cluster".
  • cluster : The name of an external cluster registered via LBFactory. If not specified, the primary DB cluster for the wiki will be used. This can be overridden with a custom cluster so that DB handles will be retrieved via LBFactory::getExternalLB() and getConnection().

Reimplemented from MediaWiki\JobQueue\JobQueue.

Definition at line 75 of file JobQueueDB.php.

Member Function Documentation

◆ claimOldest()

MediaWiki\JobQueue\JobQueueDB::claimOldest ( $uuid)
protected

Reserve a row with a single UPDATE without holding row locks over RTTs...

Parameters
string$uuid32 char hex string
Returns
stdClass|false Row|false

Definition at line 456 of file JobQueueDB.php.

References MediaWiki\JobQueue\JobQueueDB\getPrimaryDB(), and wfDebug().

Referenced by MediaWiki\JobQueue\JobQueueDB\doPop().

◆ claimRandom()

MediaWiki\JobQueue\JobQueueDB::claimRandom ( $uuid,
$rand,
$gte )
protected

Reserve a row with a single UPDATE without holding row locks over RTTs...

Parameters
string$uuid32 char hex string
int$randRandom unsigned integer (31 bits)
bool$gteSearch for job_random >= $random (otherwise job_random <= $random)
Returns
stdClass|false Row|false

Definition at line 366 of file JobQueueDB.php.

References MediaWiki\JobQueue\JobQueueDB\getPrimaryDB().

Referenced by MediaWiki\JobQueue\JobQueueDB\doPop().

◆ doAck()

MediaWiki\JobQueue\JobQueueDB::doAck ( RunnableJob $job)
protected
See also
JobQueue::doAck()
Parameters
RunnableJob$job
Exceptions
JobQueueConnectionError
JobQueueError

Reimplemented from MediaWiki\JobQueue\JobQueue.

Definition at line 522 of file JobQueueDB.php.

References $job, MediaWiki\JobQueue\JobQueueDB\getDBException(), MediaWiki\JobQueue\JobQueueDB\getPrimaryDB(), and MediaWiki\JobQueue\JobQueue\incrStats().

◆ doBatchPush()

MediaWiki\JobQueue\JobQueueDB::doBatchPush ( array $jobs,
$flags )
protected
See also
JobQueue::doBatchPush()
Parameters
IJobSpecification[]$jobs
int$flags
Exceptions
DBError|

\Exception

Returns
void

Reimplemented from MediaWiki\JobQueue\JobQueue.

Definition at line 221 of file JobQueueDB.php.

References MediaWiki\JobQueue\JobQueueDB\doBatchPushInternal(), MediaWiki\JobQueue\JobQueueDB\getPrimaryDB(), and Profiler\instance().

◆ doBatchPushInternal()

MediaWiki\JobQueue\JobQueueDB::doBatchPushInternal ( IDatabase $dbw,
array $jobs,
$flags,
$method )

◆ doDeduplicateRootJob()

MediaWiki\JobQueue\JobQueueDB::doDeduplicateRootJob ( IJobSpecification $job)
protected
See also
JobQueue::doDeduplicateRootJob()
Parameters
IJobSpecification$job
Exceptions
JobQueueConnectionError
Returns
bool

Reimplemented from MediaWiki\JobQueue\JobQueue.

Definition at line 548 of file JobQueueDB.php.

References $job, and MediaWiki\JobQueue\JobQueueDB\getPrimaryDB().

◆ doDelete()

MediaWiki\JobQueue\JobQueueDB::doDelete ( )
protected
See also
JobQueue::doDelete()
Returns
bool

Reimplemented from MediaWiki\JobQueue\JobQueue.

Definition at line 569 of file JobQueueDB.php.

References MediaWiki\JobQueue\JobQueueDB\getDBException(), and MediaWiki\JobQueue\JobQueueDB\getPrimaryDB().

◆ doFlushCaches()

MediaWiki\JobQueue\JobQueueDB::doFlushCaches ( )
protected
Returns
void

Reimplemented from MediaWiki\JobQueue\JobQueue.

Definition at line 599 of file JobQueueDB.php.

References MediaWiki\JobQueue\JobQueue\$type.

◆ doGetAbandonedCount()

MediaWiki\JobQueue\JobQueueDB::doGetAbandonedCount ( )
protected
See also
JobQueue::doGetAbandonedCount()
Returns
int
Exceptions
JobQueueConnectionError
JobQueueError

Reimplemented from MediaWiki\JobQueue\JobQueue.

Definition at line 181 of file JobQueueDB.php.

References MediaWiki\JobQueue\JobQueueDB\getDBException(), and MediaWiki\JobQueue\JobQueueDB\getReplicaDB().

◆ doGetAcquiredCount()

MediaWiki\JobQueue\JobQueueDB::doGetAcquiredCount ( )
protected
See also
JobQueue::doGetAcquiredCount()
Returns
int

Reimplemented from MediaWiki\JobQueue\JobQueue.

Definition at line 146 of file JobQueueDB.php.

References MediaWiki\JobQueue\JobQueueDB\getDBException(), and MediaWiki\JobQueue\JobQueueDB\getReplicaDB().

◆ doGetSiblingQueueSizes()

MediaWiki\JobQueue\JobQueueDB::doGetSiblingQueueSizes ( array $types)
protected
Stability: stable
to override
See also
JobQueue::getSiblingQueuesSize()
Parameters
array$typesList of queues types
Returns
array|null (list of queue types) or null if unsupported

Reimplemented from MediaWiki\JobQueue\JobQueue.

Definition at line 688 of file JobQueueDB.php.

References MediaWiki\JobQueue\JobQueueDB\getReplicaDB().

◆ doGetSiblingQueuesWithJobs()

MediaWiki\JobQueue\JobQueueDB::doGetSiblingQueuesWithJobs ( array $types)
protected
Stability: stable
to override
See also
JobQueue::getSiblingQueuesWithJobs()
Parameters
array$typesList of queues types
Returns
array|null (list of queue types) or null if unsupported

Reimplemented from MediaWiki\JobQueue\JobQueue.

Definition at line 667 of file JobQueueDB.php.

References MediaWiki\JobQueue\JobQueueDB\getReplicaDB().

◆ doGetSize()

MediaWiki\JobQueue\JobQueueDB::doGetSize ( )
protected
See also
JobQueue::doGetSize()
Returns
int

Reimplemented from MediaWiki\JobQueue\JobQueue.

Definition at line 120 of file JobQueueDB.php.

References MediaWiki\JobQueue\JobQueueDB\getDBException(), and MediaWiki\JobQueue\JobQueueDB\getReplicaDB().

◆ doIsEmpty()

MediaWiki\JobQueue\JobQueueDB::doIsEmpty ( )
protected
See also
JobQueue::doIsEmpty()
Returns
bool

Reimplemented from MediaWiki\JobQueue\JobQueue.

Definition at line 100 of file JobQueueDB.php.

References MediaWiki\JobQueue\JobQueueDB\getDBException(), and MediaWiki\JobQueue\JobQueueDB\getReplicaDB().

◆ doPop()

◆ doWaitForBackups()

MediaWiki\JobQueue\JobQueueDB::doWaitForBackups ( )
protected
See also
JobQueue::doWaitForBackups()
Returns
void

Reimplemented from MediaWiki\JobQueue\JobQueue.

Definition at line 587 of file JobQueueDB.php.

References MediaWiki\MediaWikiServices\getInstance().

◆ getAllAbandonedJobs()

MediaWiki\JobQueue\JobQueueDB::getAllAbandonedJobs ( )
See also
JobQueue::getAllAbandonedJobs()
Returns
\Iterator<RunnableJob>

Reimplemented from MediaWiki\JobQueue\JobQueue.

Definition at line 626 of file JobQueueDB.php.

References MediaWiki\JobQueue\JobQueueDB\getJobIterator(), MediaWiki\JobQueue\JobQueueDB\getReplicaDB(), and MediaWiki\JobQueue\JobQueue\getType().

◆ getAllAcquiredJobs()

MediaWiki\JobQueue\JobQueueDB::getAllAcquiredJobs ( )
See also
JobQueue::getAllAcquiredJobs()
Returns
\Iterator<RunnableJob>

Reimplemented from MediaWiki\JobQueue\JobQueue.

Definition at line 617 of file JobQueueDB.php.

References MediaWiki\JobQueue\JobQueueDB\getJobIterator(), MediaWiki\JobQueue\JobQueueDB\getReplicaDB(), and MediaWiki\JobQueue\JobQueue\getType().

◆ getAllQueuedJobs()

MediaWiki\JobQueue\JobQueueDB::getAllQueuedJobs ( )
See also
JobQueue::getAllQueuedJobs()
Returns
\Iterator<RunnableJob>

Reimplemented from MediaWiki\JobQueue\JobQueue.

Definition at line 609 of file JobQueueDB.php.

References MediaWiki\JobQueue\JobQueueDB\getJobIterator(), and MediaWiki\JobQueue\JobQueue\getType().

◆ getCoalesceLocationInternal()

MediaWiki\JobQueue\JobQueueDB::getCoalesceLocationInternal ( )

Do not use this function outside of JobQueue/JobQueueGroup.

Stability: stable
to override
Returns
string|null
Since
1.22

Reimplemented from MediaWiki\JobQueue\JobQueue.

Definition at line 657 of file JobQueueDB.php.

◆ getDB()

MediaWiki\JobQueue\JobQueueDB::getDB ( $index)
protected
Parameters
int$index(DB_REPLICA/DB_PRIMARY)
Returns
IMaintainableDatabase

Definition at line 858 of file JobQueueDB.php.

References MediaWiki\JobQueue\JobQueueDB\$conn, and MediaWiki\MediaWikiServices\getInstance().

Referenced by MediaWiki\JobQueue\JobQueueDB\getPrimaryDB(), and MediaWiki\JobQueue\JobQueueDB\getReplicaDB().

◆ getDBException()

◆ getJobIterator()

MediaWiki\JobQueue\JobQueueDB::getJobIterator ( array $conds)
protected

◆ getPrimaryDB()

◆ getReplicaDB()

◆ insertFields()

MediaWiki\JobQueue\JobQueueDB::insertFields ( IJobSpecification $job,
IReadableDatabase $db )
protected
Parameters
IJobSpecification$job
IReadableDatabase$db
Returns
array

Definition at line 812 of file JobQueueDB.php.

References $job, MediaWiki\JobQueue\JobQueueDB\makeBlob(), NS_SPECIAL, and Wikimedia\Rdbms\Platform\ISQLPlatform\timestamp().

Referenced by MediaWiki\JobQueue\JobQueueDB\doBatchPushInternal().

◆ jobFromRow()

MediaWiki\JobQueue\JobQueueDB::jobFromRow ( $row)
protected
Parameters
stdClass$row
Returns
RunnableJob

Definition at line 928 of file JobQueueDB.php.

References $job, and MediaWiki\JobQueue\JobQueue\factoryJob().

Referenced by MediaWiki\JobQueue\JobQueueDB\doPop(), and MediaWiki\JobQueue\JobQueueDB\getJobIterator().

◆ makeBlob()

static MediaWiki\JobQueue\JobQueueDB::makeBlob ( $params)
staticprotected
Parameters
array | false$params
Returns
string

Definition at line 916 of file JobQueueDB.php.

Referenced by MediaWiki\JobQueue\JobQueueDB\insertFields().

◆ optimalOrder()

MediaWiki\JobQueue\JobQueueDB::optimalOrder ( )
protected

Get the default queue order to use if configuration does not specify one.

Returns
string One of (random, timestamp, fifo, undefined)

Reimplemented from MediaWiki\JobQueue\JobQueue.

Definition at line 92 of file JobQueueDB.php.

◆ recycleAndDeleteStaleJobs()

MediaWiki\JobQueue\JobQueueDB::recycleAndDeleteStaleJobs ( )

Recycle or destroy any jobs that have been claimed for too long.

Returns
int Number of jobs recycled/deleted

Definition at line 711 of file JobQueueDB.php.

References MediaWiki\JobQueue\JobQueueDB\getDBException(), MediaWiki\JobQueue\JobQueueDB\getPrimaryDB(), and MediaWiki\JobQueue\JobQueue\incrStats().

Referenced by MediaWiki\JobQueue\JobQueueDB\doPop().

◆ selectFields()

static MediaWiki\JobQueue\JobQueueDB::selectFields ( )
static

Return the list of job fields that should be selected.

Since
1.23
Returns
array

Definition at line 956 of file JobQueueDB.php.

◆ supportedOrders()

MediaWiki\JobQueue\JobQueueDB::supportedOrders ( )
protected

Get the allowed queue orders for configuration validation.

Returns
array Subset of (random, timestamp, fifo, undefined)

Reimplemented from MediaWiki\JobQueue\JobQueue.

Definition at line 88 of file JobQueueDB.php.

Member Data Documentation

◆ $cluster

string null MediaWiki\JobQueue\JobQueueDB::$cluster
protected

Name of an external DB cluster or null for the local DB cluster.

Definition at line 65 of file JobQueueDB.php.

◆ $conn

IMaintainableDatabase DBError null MediaWiki\JobQueue\JobQueueDB::$conn
protected

Definition at line 60 of file JobQueueDB.php.

Referenced by MediaWiki\JobQueue\JobQueueDB\getDB().

◆ $server

array null MediaWiki\JobQueue\JobQueueDB::$server
protected

Server configuration array.

Definition at line 63 of file JobQueueDB.php.


The documentation for this class was generated from the following file: