MediaWiki
1.34.0
|
Class to handle job queues stored in Redis. More...
Public Member Functions | |
__construct (array $params) | |
getAllAbandonedJobs () | |
getAllAcquiredJobs () | |
getAllDelayedJobs () | |
getAllQueuedJobs () | |
getCoalesceLocationInternal () | |
Do not use this function outside of JobQueue/JobQueueGroup. More... | |
getJobFromUidInternal ( $uid, $conn) | |
This function should not be called outside JobQueueRedis. More... | |
getServerQueuesWithJobs () | |
Public Member Functions inherited from JobQueue | |
ack (RunnableJob $job) | |
Acknowledge that a job was completed. More... | |
batchPush (array $jobs, $flags=0) | |
Push a batch of jobs into the queue. More... | |
deduplicateRootJob (IJobSpecification $job) | |
Register the "root job" of a given job into the queue for de-duplication. More... | |
delayedJobsEnabled () | |
delete () | |
Deleted all unclaimed and delayed jobs from the queue. More... | |
flushCaches () | |
Clear any process and persistent caches. More... | |
getAbandonedCount () | |
Get the number of acquired jobs that can no longer be attempted. More... | |
getAcquiredCount () | |
Get the number of acquired jobs (these are temporarily out of the queue). More... | |
getDelayedCount () | |
Get the number of delayed jobs (these are temporarily out of the queue). More... | |
getDomain () | |
getOrder () | |
getReadOnlyReason () | |
getSiblingQueueSizes (array $types) | |
Check the size of each of the given queues. More... | |
getSiblingQueuesWithJobs (array $types) | |
Check whether each of the given queues are empty. More... | |
getSize () | |
Get the number of available (unacquired, non-delayed) jobs in the queue. More... | |
getType () | |
getWiki () | |
isEmpty () | |
Quickly check if the queue has no available (unacquired, non-delayed) jobs. More... | |
pop () | |
Pop a job off of the queue. More... | |
push ( $jobs, $flags=0) | |
Push one or more jobs into the queue. More... | |
waitForBackups () | |
Wait for any replica DBs or backup servers to catch up. More... | |
Public Attributes | |
const | MAX_PUSH_SIZE = 25 |
Public Attributes inherited from JobQueue | |
const | QOS_ATOMIC = 1 |
const | ROOTJOB_TTL = 2419200 |
Protected Member Functions | |
doAck (RunnableJob $job) | |
doBatchPush (array $jobs, $flags) | |
doDeduplicateRootJob (IJobSpecification $job) | |
doDelete () | |
doGetAbandonedCount () | |
doGetAcquiredCount () | |
doGetDelayedCount () | |
doGetSiblingQueueSizes (array $types) | |
doGetSiblingQueuesWithJobs (array $types) | |
doGetSize () | |
doIsEmpty () | |
doIsRootJobOldDuplicate (IJobSpecification $job) | |
doPop () | |
getConnection () | |
Get a connection to the server that handles all sub-queues for this queue. More... | |
getJobFromFields (array $fields) | |
getJobIterator (RedisConnRef $conn, array $uids) | |
getNewJobFields (IJobSpecification $job) | |
handleErrorAndMakeException (RedisConnRef $conn, $e) | |
optimalOrder () | |
Get the default queue order to use if configuration does not specify one. More... | |
popAndAcquireBlob (RedisConnRef $conn) | |
pushBlobs (RedisConnRef $conn, array $items) | |
serialize (array $fields) | |
supportedOrders () | |
Get the allowed queue orders for configuration validation. More... | |
supportsDelayedJobs () | |
Find out if delayed jobs are supported for configuration validation. More... | |
unserialize ( $blob) | |
Protected Member Functions inherited from JobQueue | |
assertNotReadOnly () | |
doFlushCaches () | |
doWaitForBackups () | |
factoryJob ( $command, $params) | |
getRootJobCacheKey ( $signature) | |
incrStats ( $key, $type, $delta=1) | |
Call wfIncrStats() for the queue overall and for the queue type. More... | |
isRootJobOldDuplicate (IJobSpecification $job) | |
Check if the "root" job of a given job has been superseded by a newer one. More... | |
Protected Attributes | |
string | $compression |
Compression method to use. More... | |
LoggerInterface | $logger |
RedisConnectionPool | $redisPool |
string | $server |
Server address. More... | |
Protected Attributes inherited from JobQueue | |
int | $claimTTL |
Time to live in seconds. More... | |
string | $domain |
DB domain ID. More... | |
int | $maxTries |
Maximum number of times to try a job. More... | |
string | $order |
Job priority for pop() More... | |
string bool | $readOnlyReason |
Read only rationale (or false if r/w) More... | |
StatsdDataFactoryInterface | $stats |
string | $type |
Job type. More... | |
WANObjectCache | $wanCache |
Private Member Functions | |
decodeQueueName ( $name) | |
encodeQueueName () | |
getGlobalKey ( $name) | |
getQueueKey ( $prop, $type=null) | |
Additional Inherited Members | |
Static Public Member Functions inherited from JobQueue | |
static | factory (array $params) |
Get a job queue object of the specified type. More... | |
Class to handle job queues stored in Redis.
This is a faster and less resource-intensive job queue than JobQueueDB. All data for a queue using this class is placed into one redis server. The mediawiki/services/jobrunner background service must be set up and running.
There are eight main redis keys (per queue) used to track jobs:
The following keys are used to track queue states:
The background service takes care of undelaying, recycling, and pruning jobs as well as removing s-queuesWithJobs entries as queues empty.
Additionally, "rootjob:* keys track "root jobs" used for additional de-duplication. Aside from root job keys, all keys have no expiry, and are only removed when jobs are run. All the keys are prefixed with the relevant wiki ID information.
This class requires Redis 2.6 as it makes use Lua scripts for fast atomic operations. Additionally, it should be noted that redis has different persistence modes, such as rdb snapshots, journaling, and no persistence. Appropriate configuration should be made on the servers based on what queues are using it and what tolerance they have.
Definition at line 68 of file JobQueueRedis.php.
JobQueueRedis::__construct | ( | array | $params | ) |
array | $params | Possible keys:
|
InvalidArgumentException |
Reimplemented from JobQueue.
Definition at line 94 of file JobQueueRedis.php.
References RedisConnectionPool\singleton().
|
private |
string | $name | JSON |
Definition at line 792 of file JobQueueRedis.php.
Referenced by getServerQueuesWithJobs().
|
protected |
RunnableJob | $job |
UnexpectedValueException | |
JobQueueError |
Reimplemented from JobQueue.
Definition at line 389 of file JobQueueRedis.php.
References $job, $res, getConnection(), getQueueKey(), handleErrorAndMakeException(), JobQueue\incrStats(), and wfDebugLog().
|
protected |
IJobSpecification[] | $jobs | |
int | $flags |
JobQueueError |
Reimplemented from JobQueue.
Definition at line 196 of file JobQueueRedis.php.
References $job, getConnection(), getNewJobFields(), handleErrorAndMakeException(), JobQueue\incrStats(), pushBlobs(), and wfDebugLog().
|
protected |
IJobSpecification | $job |
JobQueueError | |
LogicException |
Reimplemented from JobQueue.
Definition at line 444 of file JobQueueRedis.php.
References $job, getConnection(), JobQueue\getRootJobCacheKey(), and handleErrorAndMakeException().
|
protected |
JobQueueError |
Reimplemented from JobQueue.
Definition at line 495 of file JobQueueRedis.php.
References $keys, encodeQueueName(), getConnection(), getGlobalKey(), getQueueKey(), and handleErrorAndMakeException().
|
protected |
JobQueueError |
Reimplemented from JobQueue.
Definition at line 180 of file JobQueueRedis.php.
References getConnection(), getQueueKey(), and handleErrorAndMakeException().
|
protected |
JobQueueError |
Reimplemented from JobQueue.
Definition at line 148 of file JobQueueRedis.php.
References getConnection(), getQueueKey(), and handleErrorAndMakeException().
|
protected |
JobQueueError |
Reimplemented from JobQueue.
Definition at line 166 of file JobQueueRedis.php.
References getConnection(), getQueueKey(), and handleErrorAndMakeException().
|
protected |
array | $types | List of queues types |
Reimplemented from JobQueue.
Definition at line 604 of file JobQueueRedis.php.
References $res, JobQueue\$type, getConnection(), getQueueKey(), and handleErrorAndMakeException().
Referenced by doGetSiblingQueuesWithJobs().
|
protected |
array | $types | List of queues types |
Reimplemented from JobQueue.
Definition at line 600 of file JobQueueRedis.php.
References doGetSiblingQueueSizes().
|
protected |
JobQueueError |
Reimplemented from JobQueue.
Definition at line 134 of file JobQueueRedis.php.
References getConnection(), getQueueKey(), and handleErrorAndMakeException().
Referenced by doIsEmpty().
|
protected |
JobQueueError |
Reimplemented from JobQueue.
Definition at line 125 of file JobQueueRedis.php.
References doGetSize().
|
protected |
IJobSpecification | $job |
JobQueueError |
Reimplemented from JobQueue.
Definition at line 472 of file JobQueueRedis.php.
References $job, getConnection(), JobQueue\getRootJobCacheKey(), and handleErrorAndMakeException().
|
protected |
JobQueueError |
Reimplemented from JobQueue.
Definition at line 315 of file JobQueueRedis.php.
References $blob, $job, getConnection(), getJobFromFields(), handleErrorAndMakeException(), JobQueue\incrStats(), popAndAcquireBlob(), unserialize(), and wfDebugLog().
|
private |
Definition at line 784 of file JobQueueRedis.php.
Referenced by doDelete(), and pushBlobs().
JobQueueRedis::getAllAbandonedJobs | ( | ) |
JobQueueError |
Reimplemented from JobQueue.
Definition at line 568 of file JobQueueRedis.php.
References getConnection(), getJobIterator(), getQueueKey(), and handleErrorAndMakeException().
JobQueueRedis::getAllAcquiredJobs | ( | ) |
JobQueueError |
Reimplemented from JobQueue.
Definition at line 552 of file JobQueueRedis.php.
References getConnection(), getJobIterator(), getQueueKey(), and handleErrorAndMakeException().
JobQueueRedis::getAllDelayedJobs | ( | ) |
JobQueueError |
Reimplemented from JobQueue.
Definition at line 536 of file JobQueueRedis.php.
References getConnection(), getJobIterator(), getQueueKey(), and handleErrorAndMakeException().
JobQueueRedis::getAllQueuedJobs | ( | ) |
JobQueueError |
Reimplemented from JobQueue.
Definition at line 520 of file JobQueueRedis.php.
References getConnection(), getJobIterator(), getQueueKey(), and handleErrorAndMakeException().
JobQueueRedis::getCoalesceLocationInternal | ( | ) |
Do not use this function outside of JobQueue/JobQueueGroup.
Reimplemented from JobQueue.
Definition at line 596 of file JobQueueRedis.php.
References $server.
|
protected |
Get a connection to the server that handles all sub-queues for this queue.
JobQueueConnectionError |
Definition at line 761 of file JobQueueRedis.php.
Referenced by doAck(), doBatchPush(), doDeduplicateRootJob(), doDelete(), doGetAbandonedCount(), doGetAcquiredCount(), doGetDelayedCount(), doGetSiblingQueueSizes(), doGetSize(), doIsRootJobOldDuplicate(), doPop(), getAllAbandonedJobs(), getAllAcquiredJobs(), getAllDelayedJobs(), getAllQueuedJobs(), and getServerQueuesWithJobs().
|
private |
string | $name |
Definition at line 800 of file JobQueueRedis.php.
Referenced by doDelete(), getServerQueuesWithJobs(), and pushBlobs().
|
protected |
array | $fields |
Definition at line 708 of file JobQueueRedis.php.
References $job, and JobQueue\factoryJob().
Referenced by doPop().
JobQueueRedis::getJobFromUidInternal | ( | $uid, | |
$conn | |||
) |
This function should not be called outside JobQueueRedis.
string | $uid | |
RedisConnRef | Redis | $conn |
JobQueueError | |
UnexpectedValueException |
Definition at line 635 of file JobQueueRedis.php.
References $job, JobQueue\factoryJob(), getQueueKey(), handleErrorAndMakeException(), and unserialize().
Referenced by getJobIterator().
|
protected |
RedisConnRef | $conn | |
array | $uids | List of job UUIDs |
Definition at line 584 of file JobQueueRedis.php.
References $job, and getJobFromUidInternal().
Referenced by getAllAbandonedJobs(), getAllAcquiredJobs(), getAllDelayedJobs(), and getAllQueuedJobs().
|
protected |
IJobSpecification | $job |
Definition at line 686 of file JobQueueRedis.php.
References $job, UIDGenerator\newRawUUIDv4(), NS_SPECIAL, UIDGenerator\QUICK_RAND, and serialize().
Referenced by doBatchPush().
|
private |
string | $prop | |
string | null | $type | Override this for sibling queues |
Definition at line 816 of file JobQueueRedis.php.
References JobQueue\$type, and WikiMap\getWikiIdFromDbDomain().
Referenced by doAck(), doDelete(), doGetAbandonedCount(), doGetAcquiredCount(), doGetDelayedCount(), doGetSiblingQueueSizes(), doGetSize(), getAllAbandonedJobs(), getAllAcquiredJobs(), getAllDelayedJobs(), getAllQueuedJobs(), getJobFromUidInternal(), popAndAcquireBlob(), and pushBlobs().
JobQueueRedis::getServerQueuesWithJobs | ( | ) |
JobQueueConnectionError | |
JobQueueError |
Definition at line 666 of file JobQueueRedis.php.
References $queue, decodeQueueName(), getConnection(), getGlobalKey(), and handleErrorAndMakeException().
|
protected |
RedisConnRef | $conn | |
RedisException | $e |
Definition at line 776 of file JobQueueRedis.php.
Referenced by doAck(), doBatchPush(), doDeduplicateRootJob(), doDelete(), doGetAbandonedCount(), doGetAcquiredCount(), doGetDelayedCount(), doGetSiblingQueueSizes(), doGetSize(), doIsRootJobOldDuplicate(), doPop(), getAllAbandonedJobs(), getAllAcquiredJobs(), getAllDelayedJobs(), getAllQueuedJobs(), getJobFromUidInternal(), and getServerQueuesWithJobs().
|
protected |
Get the default queue order to use if configuration does not specify one.
Reimplemented from JobQueue.
Definition at line 112 of file JobQueueRedis.php.
|
protected |
RedisConnRef | $conn |
RedisException |
Definition at line 348 of file JobQueueRedis.php.
References getQueueKey(), and RedisConnRef\luaEval().
Referenced by doPop().
|
protected |
RedisConnRef | $conn | |
array | $items | List of results from JobQueueRedis::getNewJobFields() |
RedisException |
Definition at line 250 of file JobQueueRedis.php.
References $args, encodeQueueName(), getGlobalKey(), getQueueKey(), RedisConnRef\luaEval(), and serialize().
Referenced by doBatchPush().
|
protected |
array | $fields |
Definition at line 723 of file JobQueueRedis.php.
References $blob.
Referenced by getNewJobFields(), and pushBlobs().
|
protected |
Get the allowed queue orders for configuration validation.
Reimplemented from JobQueue.
Definition at line 108 of file JobQueueRedis.php.
|
protected |
Find out if delayed jobs are supported for configuration validation.
Reimplemented from JobQueue.
Definition at line 116 of file JobQueueRedis.php.
|
protected |
string | $blob |
Definition at line 742 of file JobQueueRedis.php.
References $blob.
Referenced by doPop(), and getJobFromUidInternal().
|
protected |
Compression method to use.
Definition at line 77 of file JobQueueRedis.php.
|
protected |
Definition at line 72 of file JobQueueRedis.php.
|
protected |
Definition at line 70 of file JobQueueRedis.php.
|
protected |
Server address.
Definition at line 75 of file JobQueueRedis.php.
Referenced by getCoalesceLocationInternal().
const JobQueueRedis::MAX_PUSH_SIZE = 25 |
Definition at line 79 of file JobQueueRedis.php.