Change-Id: Ibd04ca3e862134ea591397ff29e05ee041f278a8
* @since 1.20
*/
class JobQueueDB extends JobQueue {
* @since 1.20
*/
class JobQueueDB extends JobQueue {
- const CACHE_TTL = 30; // integer; seconds
+ const CACHE_TTL = 30; // integer; seconds
+ const MAX_JOB_RANDOM = 2147483647; // [0, 2^31 - 1]
/**
* @see JobQueue::doIsEmpty()
/**
* @see JobQueue::doIsEmpty()
try {
do { // retry when our row is invalid or deleted as a duplicate
$row = false; // row claimed
try {
do { // retry when our row is invalid or deleted as a duplicate
$row = false; // row claimed
- $rand = mt_rand( 0, 2147483648 ); // encourage concurrent UPDATEs
+ $rand = mt_rand( 0, self::MAX_JOB_RANDOM ); // encourage concurrent UPDATEs
$gte = (bool)mt_rand( 0, 1 ); // find rows with rand before/after $rand
// Try to reserve a DB row...
if ( $this->claim( $uuid, $rand, $gte ) || $this->claim( $uuid, $rand, !$gte ) ) {
$gte = (bool)mt_rand( 0, 1 ); // find rows with rand before/after $rand
// Try to reserve a DB row...
if ( $this->claim( $uuid, $rand, $gte ) || $this->claim( $uuid, $rand, !$gte ) ) {
'job_id' => $dbw->nextSequenceValue( 'job_job_id_seq' ),
'job_timestamp' => $dbw->timestamp(),
'job_sha1' => wfBaseConvert( sha1( serialize( $descFields ) ), 16, 36, 32 ),
'job_id' => $dbw->nextSequenceValue( 'job_job_id_seq' ),
'job_timestamp' => $dbw->timestamp(),
'job_sha1' => wfBaseConvert( sha1( serialize( $descFields ) ), 16, 36, 32 ),
- 'job_random' => mt_rand( 0, 2147483647 ) // [0, 2^31 - 1]
+ 'job_random' => mt_rand( 0, self::MAX_JOB_RANDOM )
);
return ( $descFields + $metaFields );
}
);
return ( $descFields + $metaFields );
}