3 * Database-backed job queue code.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @author Aaron Schulz
23 use Wikimedia\Rdbms\IDatabase
;
24 use MediaWiki\MediaWikiServices
;
25 use Wikimedia\ScopedCallback
;
28 * Class to handle job queues stored in the DB
33 class JobQueueDB
extends JobQueue
{
34 const CACHE_TTL_SHORT
= 30; // integer; seconds to cache info without re-validating
35 const MAX_AGE_PRUNE
= 604800; // integer; seconds a job can live once claimed
36 const MAX_JOB_RANDOM
= 2147483647; // integer; 2^31 - 1, used for job_random
37 const MAX_OFFSET
= 255; // integer; maximum number of rows to skip
39 /** @var WANObjectCache */
42 /** @var bool|string Name of an external DB cluster. False if not set */
43 protected $cluster = false;
46 * Additional parameters include:
47 * - cluster : The name of an external cluster registered via LBFactory.
48 * If not specified, the primary DB cluster for the wiki will be used.
49 * This can be overridden with a custom cluster so that DB handles will
50 * be retrieved via LBFactory::getExternalLB() and getConnection().
51 * @param array $params
53 protected function __construct( array $params ) {
54 parent
::__construct( $params );
56 $this->cluster
= isset( $params['cluster'] ) ?
$params['cluster'] : false;
57 $this->cache
= ObjectCache
::getMainWANInstance();
60 protected function supportedOrders() {
61 return [ 'random', 'timestamp', 'fifo' ];
64 protected function optimalOrder() {
69 * @see JobQueue::doIsEmpty()
72 protected function doIsEmpty() {
73 $dbr = $this->getReplicaDB();
75 $found = $dbr->selectField( // unclaimed job
76 'job', '1', [ 'job_cmd' => $this->type
, 'job_token' => '' ], __METHOD__
78 } catch ( DBError
$e ) {
79 $this->throwDBException( $e );
86 * @see JobQueue::doGetSize()
89 protected function doGetSize() {
90 $key = $this->getCacheKey( 'size' );
92 $size = $this->cache
->get( $key );
93 if ( is_int( $size ) ) {
98 $dbr = $this->getReplicaDB();
99 $size = (int)$dbr->selectField( 'job', 'COUNT(*)',
100 [ 'job_cmd' => $this->type
, 'job_token' => '' ],
103 } catch ( DBError
$e ) {
104 $this->throwDBException( $e );
106 $this->cache
->set( $key, $size, self
::CACHE_TTL_SHORT
);
112 * @see JobQueue::doGetAcquiredCount()
115 protected function doGetAcquiredCount() {
116 if ( $this->claimTTL
<= 0 ) {
117 return 0; // no acknowledgements
120 $key = $this->getCacheKey( 'acquiredcount' );
122 $count = $this->cache
->get( $key );
123 if ( is_int( $count ) ) {
127 $dbr = $this->getReplicaDB();
129 $count = (int)$dbr->selectField( 'job', 'COUNT(*)',
130 [ 'job_cmd' => $this->type
, "job_token != {$dbr->addQuotes( '' )}" ],
133 } catch ( DBError
$e ) {
134 $this->throwDBException( $e );
136 $this->cache
->set( $key, $count, self
::CACHE_TTL_SHORT
);
142 * @see JobQueue::doGetAbandonedCount()
144 * @throws MWException
146 protected function doGetAbandonedCount() {
147 if ( $this->claimTTL
<= 0 ) {
148 return 0; // no acknowledgements
151 $key = $this->getCacheKey( 'abandonedcount' );
153 $count = $this->cache
->get( $key );
154 if ( is_int( $count ) ) {
158 $dbr = $this->getReplicaDB();
160 $count = (int)$dbr->selectField( 'job', 'COUNT(*)',
162 'job_cmd' => $this->type
,
163 "job_token != {$dbr->addQuotes( '' )}",
164 "job_attempts >= " . $dbr->addQuotes( $this->maxTries
)
168 } catch ( DBError
$e ) {
169 $this->throwDBException( $e );
172 $this->cache
->set( $key, $count, self
::CACHE_TTL_SHORT
);
178 * @see JobQueue::doBatchPush()
179 * @param IJobSpecification[] $jobs
181 * @throws DBError|Exception
184 protected function doBatchPush( array $jobs, $flags ) {
185 $dbw = $this->getMasterDB();
187 $method = __METHOD__
;
188 $dbw->onTransactionIdle(
189 function () use ( $dbw, $jobs, $flags, $method ) {
190 $this->doBatchPushInternal( $dbw, $jobs, $flags, $method );
197 * This function should *not* be called outside of JobQueueDB
199 * @param IDatabase $dbw
200 * @param IJobSpecification[] $jobs
202 * @param string $method
206 public function doBatchPushInternal( IDatabase
$dbw, array $jobs, $flags, $method ) {
207 if ( !count( $jobs ) ) {
211 $rowSet = []; // (sha1 => job) map for jobs that are de-duplicated
212 $rowList = []; // list of jobs for jobs that are not de-duplicated
213 foreach ( $jobs as $job ) {
214 $row = $this->insertFields( $job );
215 if ( $job->ignoreDuplicates() ) {
216 $rowSet[$row['job_sha1']] = $row;
222 if ( $flags & self
::QOS_ATOMIC
) {
223 $dbw->startAtomic( $method ); // wrap all the job additions in one transaction
226 // Strip out any duplicate jobs that are already in the queue...
227 if ( count( $rowSet ) ) {
228 $res = $dbw->select( 'job', 'job_sha1',
230 // No job_type condition since it's part of the job_sha1 hash
231 'job_sha1' => array_keys( $rowSet ),
232 'job_token' => '' // unclaimed
236 foreach ( $res as $row ) {
237 wfDebug( "Job with hash '{$row->job_sha1}' is a duplicate.\n" );
238 unset( $rowSet[$row->job_sha1
] ); // already enqueued
241 // Build the full list of job rows to insert
242 $rows = array_merge( $rowList, array_values( $rowSet ) );
243 // Insert the job rows in chunks to avoid replica DB lag...
244 foreach ( array_chunk( $rows, 50 ) as $rowBatch ) {
245 $dbw->insert( 'job', $rowBatch, $method );
247 JobQueue
::incrStats( 'inserts', $this->type
, count( $rows ) );
248 JobQueue
::incrStats( 'dupe_inserts', $this->type
,
249 count( $rowSet ) +
count( $rowList ) - count( $rows )
251 } catch ( DBError
$e ) {
252 $this->throwDBException( $e );
254 if ( $flags & self
::QOS_ATOMIC
) {
255 $dbw->endAtomic( $method );
262 * @see JobQueue::doPop()
265 protected function doPop() {
266 $dbw = $this->getMasterDB();
268 $autoTrx = $dbw->getFlag( DBO_TRX
); // get current setting
269 $dbw->clearFlag( DBO_TRX
); // make each query its own transaction
270 $scopedReset = new ScopedCallback( function () use ( $dbw, $autoTrx ) {
271 $dbw->setFlag( $autoTrx ? DBO_TRX
: 0 ); // restore old setting
274 $uuid = wfRandomString( 32 ); // pop attempt
275 $job = false; // job popped off
276 do { // retry when our row is invalid or deleted as a duplicate
277 // Try to reserve a row in the DB...
278 if ( in_array( $this->order
, [ 'fifo', 'timestamp' ] ) ) {
279 $row = $this->claimOldest( $uuid );
280 } else { // random first
281 $rand = mt_rand( 0, self
::MAX_JOB_RANDOM
); // encourage concurrent UPDATEs
282 $gte = (bool)mt_rand( 0, 1 ); // find rows with rand before/after $rand
283 $row = $this->claimRandom( $uuid, $rand, $gte );
285 // Check if we found a row to reserve...
287 break; // nothing to do
289 JobQueue
::incrStats( 'pops', $this->type
);
290 // Get the job object from the row...
291 $title = Title
::makeTitle( $row->job_namespace
, $row->job_title
);
292 $job = Job
::factory( $row->job_cmd
, $title,
293 self
::extractBlob( $row->job_params
), $row->job_id
);
294 $job->metadata
['id'] = $row->job_id
;
295 $job->metadata
['timestamp'] = $row->job_timestamp
;
299 if ( !$job ||
mt_rand( 0, 9 ) == 0 ) {
300 // Handled jobs that need to be recycled/deleted;
301 // any recycled jobs will be picked up next attempt
302 $this->recycleAndDeleteStaleJobs();
304 } catch ( DBError
$e ) {
305 $this->throwDBException( $e );
312 * Reserve a row with a single UPDATE without holding row locks over RTTs...
314 * @param string $uuid 32 char hex string
315 * @param int $rand Random unsigned integer (31 bits)
316 * @param bool $gte Search for job_random >= $random (otherwise job_random <= $random)
317 * @return stdClass|bool Row|false
319 protected function claimRandom( $uuid, $rand, $gte ) {
320 $dbw = $this->getMasterDB();
321 // Check cache to see if the queue has <= OFFSET items
322 $tinyQueue = $this->cache
->get( $this->getCacheKey( 'small' ) );
324 $row = false; // the row acquired
325 $invertedDirection = false; // whether one job_random direction was already scanned
326 // This uses a replication safe method for acquiring jobs. One could use UPDATE+LIMIT
327 // instead, but that either uses ORDER BY (in which case it deadlocks in MySQL) or is
328 // not replication safe. Due to https://bugs.mysql.com/bug.php?id=6980, subqueries cannot
329 // be used here with MySQL.
331 if ( $tinyQueue ) { // queue has <= MAX_OFFSET rows
332 // For small queues, using OFFSET will overshoot and return no rows more often.
333 // Instead, this uses job_random to pick a row (possibly checking both directions).
334 $ineq = $gte ?
'>=' : '<=';
335 $dir = $gte ?
'ASC' : 'DESC';
336 $row = $dbw->selectRow( 'job', self
::selectFields(), // find a random job
338 'job_cmd' => $this->type
,
339 'job_token' => '', // unclaimed
340 "job_random {$ineq} {$dbw->addQuotes( $rand )}" ],
342 [ 'ORDER BY' => "job_random {$dir}" ]
344 if ( !$row && !$invertedDirection ) {
346 $invertedDirection = true;
347 continue; // try the other direction
349 } else { // table *may* have >= MAX_OFFSET rows
350 // T44614: "ORDER BY job_random" with a job_random inequality causes high CPU
351 // in MySQL if there are many rows for some reason. This uses a small OFFSET
352 // instead of job_random for reducing excess claim retries.
353 $row = $dbw->selectRow( 'job', self
::selectFields(), // find a random job
355 'job_cmd' => $this->type
,
356 'job_token' => '', // unclaimed
359 [ 'OFFSET' => mt_rand( 0, self
::MAX_OFFSET
) ]
362 $tinyQueue = true; // we know the queue must have <= MAX_OFFSET rows
363 $this->cache
->set( $this->getCacheKey( 'small' ), 1, 30 );
364 continue; // use job_random
368 if ( $row ) { // claim the job
369 $dbw->update( 'job', // update by PK
371 'job_token' => $uuid,
372 'job_token_timestamp' => $dbw->timestamp(),
373 'job_attempts = job_attempts+1' ],
374 [ 'job_cmd' => $this->type
, 'job_id' => $row->job_id
, 'job_token' => '' ],
377 // This might get raced out by another runner when claiming the previously
378 // selected row. The use of job_random should minimize this problem, however.
379 if ( !$dbw->affectedRows() ) {
380 $row = false; // raced out
383 break; // nothing to do
391 * Reserve a row with a single UPDATE without holding row locks over RTTs...
393 * @param string $uuid 32 char hex string
394 * @return stdClass|bool Row|false
396 protected function claimOldest( $uuid ) {
397 $dbw = $this->getMasterDB();
399 $row = false; // the row acquired
401 if ( $dbw->getType() === 'mysql' ) {
402 // Per https://bugs.mysql.com/bug.php?id=6980, we can't use subqueries on the
403 // same table being changed in an UPDATE query in MySQL (gives Error: 1093).
404 // Oracle and Postgre have no such limitation. However, MySQL offers an
405 // alternative here by supporting ORDER BY + LIMIT for UPDATE queries.
406 $dbw->query( "UPDATE {$dbw->tableName( 'job' )} " .
408 "job_token = {$dbw->addQuotes( $uuid ) }, " .
409 "job_token_timestamp = {$dbw->addQuotes( $dbw->timestamp() )}, " .
410 "job_attempts = job_attempts+1 " .
412 "job_cmd = {$dbw->addQuotes( $this->type )} " .
413 "AND job_token = {$dbw->addQuotes( '' )} " .
414 ") ORDER BY job_id ASC LIMIT 1",
418 // Use a subquery to find the job, within an UPDATE to claim it.
419 // This uses as much of the DB wrapper functions as possible.
422 'job_token' => $uuid,
423 'job_token_timestamp' => $dbw->timestamp(),
424 'job_attempts = job_attempts+1' ],
426 $dbw->selectSQLText( 'job', 'job_id',
427 [ 'job_cmd' => $this->type
, 'job_token' => '' ],
429 [ 'ORDER BY' => 'job_id ASC', 'LIMIT' => 1 ] ) .
435 // Fetch any row that we just reserved...
436 if ( $dbw->affectedRows() ) {
437 $row = $dbw->selectRow( 'job', self
::selectFields(),
438 [ 'job_cmd' => $this->type
, 'job_token' => $uuid ], __METHOD__
440 if ( !$row ) { // raced out by duplicate job removal
441 wfDebug( "Row deleted as duplicate by another process.\n" );
444 break; // nothing to do
452 * @see JobQueue::doAck()
454 * @throws MWException
456 protected function doAck( Job
$job ) {
457 if ( !isset( $job->metadata
['id'] ) ) {
458 throw new MWException( "Job of type '{$job->getType()}' has no ID." );
461 $dbw = $this->getMasterDB();
463 $autoTrx = $dbw->getFlag( DBO_TRX
); // get current setting
464 $dbw->clearFlag( DBO_TRX
); // make each query its own transaction
465 $scopedReset = new ScopedCallback( function () use ( $dbw, $autoTrx ) {
466 $dbw->setFlag( $autoTrx ? DBO_TRX
: 0 ); // restore old setting
469 // Delete a row with a single DELETE without holding row locks over RTTs...
471 [ 'job_cmd' => $this->type
, 'job_id' => $job->metadata
['id'] ], __METHOD__
);
473 JobQueue
::incrStats( 'acks', $this->type
);
474 } catch ( DBError
$e ) {
475 $this->throwDBException( $e );
480 * @see JobQueue::doDeduplicateRootJob()
481 * @param IJobSpecification $job
482 * @throws MWException
485 protected function doDeduplicateRootJob( IJobSpecification
$job ) {
486 $params = $job->getParams();
487 if ( !isset( $params['rootJobSignature'] ) ) {
488 throw new MWException( "Cannot register root job; missing 'rootJobSignature'." );
489 } elseif ( !isset( $params['rootJobTimestamp'] ) ) {
490 throw new MWException( "Cannot register root job; missing 'rootJobTimestamp'." );
492 $key = $this->getRootJobCacheKey( $params['rootJobSignature'] );
493 // Callers should call batchInsert() and then this function so that if the insert
494 // fails, the de-duplication registration will be aborted. Since the insert is
495 // deferred till "transaction idle", do the same here, so that the ordering is
496 // maintained. Having only the de-duplication registration succeed would cause
497 // jobs to become no-ops without any actual jobs that made them redundant.
498 $dbw = $this->getMasterDB();
499 $cache = $this->dupCache
;
500 $dbw->onTransactionIdle(
501 function () use ( $cache, $params, $key, $dbw ) {
502 $timestamp = $cache->get( $key ); // current last timestamp of this job
503 if ( $timestamp && $timestamp >= $params['rootJobTimestamp'] ) {
504 return true; // a newer version of this root job was enqueued
507 // Update the timestamp of the last root job started at the location...
508 return $cache->set( $key, $params['rootJobTimestamp'], JobQueueDB
::ROOTJOB_TTL
);
517 * @see JobQueue::doDelete()
520 protected function doDelete() {
521 $dbw = $this->getMasterDB();
523 $dbw->delete( 'job', [ 'job_cmd' => $this->type
] );
524 } catch ( DBError
$e ) {
525 $this->throwDBException( $e );
532 * @see JobQueue::doWaitForBackups()
535 protected function doWaitForBackups() {
536 $lbFactory = MediaWikiServices
::getInstance()->getDBLoadBalancerFactory();
537 $lbFactory->waitForReplication( [ 'wiki' => $this->wiki
, 'cluster' => $this->cluster
] );
543 protected function doFlushCaches() {
544 foreach ( [ 'size', 'acquiredcount' ] as $type ) {
545 $this->cache
->delete( $this->getCacheKey( $type ) );
550 * @see JobQueue::getAllQueuedJobs()
553 public function getAllQueuedJobs() {
554 return $this->getJobIterator( [ 'job_cmd' => $this->getType(), 'job_token' => '' ] );
558 * @see JobQueue::getAllAcquiredJobs()
561 public function getAllAcquiredJobs() {
562 return $this->getJobIterator( [ 'job_cmd' => $this->getType(), "job_token > ''" ] );
566 * @param array $conds Query conditions
569 protected function getJobIterator( array $conds ) {
570 $dbr = $this->getReplicaDB();
572 return new MappedIterator(
573 $dbr->select( 'job', self
::selectFields(), $conds ),
577 Title
::makeTitle( $row->job_namespace
, $row->job_title
),
578 strlen( $row->job_params
) ?
unserialize( $row->job_params
) : []
580 $job->metadata
['id'] = $row->job_id
;
581 $job->metadata
['timestamp'] = $row->job_timestamp
;
586 } catch ( DBError
$e ) {
587 $this->throwDBException( $e );
591 public function getCoalesceLocationInternal() {
592 return $this->cluster
593 ?
"DBCluster:{$this->cluster}:{$this->wiki}"
594 : "LBFactory:{$this->wiki}";
597 protected function doGetSiblingQueuesWithJobs( array $types ) {
598 $dbr = $this->getReplicaDB();
599 // @note: this does not check whether the jobs are claimed or not.
600 // This is useful so JobQueueGroup::pop() also sees queues that only
601 // have stale jobs. This lets recycleAndDeleteStaleJobs() re-enqueue
602 // failed jobs so that they can be popped again for that edge case.
603 $res = $dbr->select( 'job', 'DISTINCT job_cmd',
604 [ 'job_cmd' => $types ], __METHOD__
);
607 foreach ( $res as $row ) {
608 $types[] = $row->job_cmd
;
614 protected function doGetSiblingQueueSizes( array $types ) {
615 $dbr = $this->getReplicaDB();
616 $res = $dbr->select( 'job', [ 'job_cmd', 'COUNT(*) AS count' ],
617 [ 'job_cmd' => $types ], __METHOD__
, [ 'GROUP BY' => 'job_cmd' ] );
620 foreach ( $res as $row ) {
621 $sizes[$row->job_cmd
] = (int)$row->count
;
628 * Recycle or destroy any jobs that have been claimed for too long
630 * @return int Number of jobs recycled/deleted
632 public function recycleAndDeleteStaleJobs() {
634 $count = 0; // affected rows
635 $dbw = $this->getMasterDB();
638 if ( !$dbw->lock( "jobqueue-recycle-{$this->type}", __METHOD__
, 1 ) ) {
639 return $count; // already in progress
642 // Remove claims on jobs acquired for too long if enabled...
643 if ( $this->claimTTL
> 0 ) {
644 $claimCutoff = $dbw->timestamp( $now - $this->claimTTL
);
645 // Get the IDs of jobs that have be claimed but not finished after too long.
646 // These jobs can be recycled into the queue by expiring the claim. Selecting
647 // the IDs first means that the UPDATE can be done by primary key (less deadlocks).
648 $res = $dbw->select( 'job', 'job_id',
650 'job_cmd' => $this->type
,
651 "job_token != {$dbw->addQuotes( '' )}", // was acquired
652 "job_token_timestamp < {$dbw->addQuotes( $claimCutoff )}", // stale
653 "job_attempts < {$dbw->addQuotes( $this->maxTries )}" ], // retries left
659 }, iterator_to_array( $res )
661 if ( count( $ids ) ) {
662 // Reset job_token for these jobs so that other runners will pick them up.
663 // Set the timestamp to the current time, as it is useful to now that the job
664 // was already tried before (the timestamp becomes the "released" time).
668 'job_token_timestamp' => $dbw->timestamp( $now ) ], // time of release
673 $affected = $dbw->affectedRows();
675 JobQueue
::incrStats( 'recycles', $this->type
, $affected );
676 $this->aggr
->notifyQueueNonEmpty( $this->wiki
, $this->type
);
680 // Just destroy any stale jobs...
681 $pruneCutoff = $dbw->timestamp( $now - self
::MAX_AGE_PRUNE
);
683 'job_cmd' => $this->type
,
684 "job_token != {$dbw->addQuotes( '' )}", // was acquired
685 "job_token_timestamp < {$dbw->addQuotes( $pruneCutoff )}" // stale
687 if ( $this->claimTTL
> 0 ) { // only prune jobs attempted too many times...
688 $conds[] = "job_attempts >= {$dbw->addQuotes( $this->maxTries )}";
690 // Get the IDs of jobs that are considered stale and should be removed. Selecting
691 // the IDs first means that the UPDATE can be done by primary key (less deadlocks).
692 $res = $dbw->select( 'job', 'job_id', $conds, __METHOD__
);
696 }, iterator_to_array( $res )
698 if ( count( $ids ) ) {
699 $dbw->delete( 'job', [ 'job_id' => $ids ], __METHOD__
);
700 $affected = $dbw->affectedRows();
702 JobQueue
::incrStats( 'abandons', $this->type
, $affected );
705 $dbw->unlock( "jobqueue-recycle-{$this->type}", __METHOD__
);
706 } catch ( DBError
$e ) {
707 $this->throwDBException( $e );
714 * @param IJobSpecification $job
717 protected function insertFields( IJobSpecification
$job ) {
718 $dbw = $this->getMasterDB();
721 // Fields that describe the nature of the job
722 'job_cmd' => $job->getType(),
723 'job_namespace' => $job->getTitle()->getNamespace(),
724 'job_title' => $job->getTitle()->getDBkey(),
725 'job_params' => self
::makeBlob( $job->getParams() ),
726 // Additional job metadata
727 'job_id' => $dbw->nextSequenceValue( 'job_job_id_seq' ),
728 'job_timestamp' => $dbw->timestamp(),
729 'job_sha1' => Wikimedia\base_convert
(
730 sha1( serialize( $job->getDeduplicationInfo() ) ),
733 'job_random' => mt_rand( 0, self
::MAX_JOB_RANDOM
)
738 * @throws JobQueueConnectionError
741 protected function getReplicaDB() {
743 return $this->getDB( DB_REPLICA
);
744 } catch ( DBConnectionError
$e ) {
745 throw new JobQueueConnectionError( "DBConnectionError:" . $e->getMessage() );
750 * @throws JobQueueConnectionError
753 protected function getMasterDB() {
755 return $this->getDB( DB_MASTER
);
756 } catch ( DBConnectionError
$e ) {
757 throw new JobQueueConnectionError( "DBConnectionError:" . $e->getMessage() );
762 * @param int $index (DB_REPLICA/DB_MASTER)
765 protected function getDB( $index ) {
766 $lbFactory = MediaWikiServices
::getInstance()->getDBLoadBalancerFactory();
767 $lb = ( $this->cluster
!== false )
768 ?
$lbFactory->getExternalLB( $this->cluster
, $this->wiki
)
769 : $lbFactory->getMainLB( $this->wiki
);
771 return $lb->getConnectionRef( $index, [], $this->wiki
);
775 * @param string $property
778 private function getCacheKey( $property ) {
779 list( $db, $prefix ) = wfSplitWikiID( $this->wiki
);
780 $cluster = is_string( $this->cluster
) ?
$this->cluster
: 'main';
782 return wfForeignMemcKey( $db, $prefix, 'jobqueue', $cluster, $this->type
, $property );
786 * @param array|bool $params
789 protected static function makeBlob( $params ) {
790 if ( $params !== false ) {
791 return serialize( $params );
798 * @param string $blob
801 protected static function extractBlob( $blob ) {
802 if ( (string)$blob !== '' ) {
803 return unserialize( $blob );
811 * @throws JobQueueError
813 protected function throwDBException( DBError
$e ) {
814 throw new JobQueueError( get_class( $e ) . ": " . $e->getMessage() );
818 * Return the list of job fields that should be selected.
822 public static function selectFields() {
833 'job_token_timestamp',