Tim Starling has submitted this change and it was merged.

Change subject: [JobQueue] Made the maximum number of job attempts configurable.
......................................................................


[JobQueue] Made the maximum number of job attempts configurable.

Change-Id: I3aaab748913af68f4a676855c5c4f825706f7be7
---
M includes/job/JobQueue.php
M includes/job/JobQueueDB.php
M includes/job/JobQueueRedis.php
3 files changed, 5 insertions(+), 5 deletions(-)

Approvals:
  Tim Starling: Verified; Looks good to me, approved
  jenkins-bot: Checked



diff --git a/includes/job/JobQueue.php b/includes/job/JobQueue.php
index 67fe180..f02ed98 100644
--- a/includes/job/JobQueue.php
+++ b/includes/job/JobQueue.php
@@ -33,10 +33,9 @@
        protected $type; // string; job type
        protected $order; // string; job priority for pop()
        protected $claimTTL; // integer; seconds
+       protected $maxTries; // integer; maximum number of times to try a job
 
        const QoS_Atomic = 1; // integer; "all-or-nothing" job insertions
-
-       const MAX_ATTEMPTS = 3; // integer; number of times to try a job
 
        /**
         * @param $params array
@@ -46,6 +45,7 @@
                $this->type     = $params['type'];
                $this->order    = isset( $params['order'] ) ? $params['order'] 
: 'random';
                $this->claimTTL = isset( $params['claimTTL'] ) ? 
$params['claimTTL'] : 0;
+               $this->maxTries = isset( $params['maxTries'] ) ? 
$params['maxTries'] : 3;
        }
 
        /**
diff --git a/includes/job/JobQueueDB.php b/includes/job/JobQueueDB.php
index f583c52..fd64895 100644
--- a/includes/job/JobQueueDB.php
+++ b/includes/job/JobQueueDB.php
@@ -423,7 +423,7 @@
                                        'job_cmd' => $this->type,
                                        "job_token != {$dbw->addQuotes( '' )}", 
// was acquired
                                        "job_token_timestamp < 
{$dbw->addQuotes( $claimCutoff )}", // stale
-                                       "job_attempts < {$dbw->addQuotes( 
self::MAX_ATTEMPTS )}" ), // retries left
+                                       "job_attempts < {$dbw->addQuotes( 
$this->maxTries )}" ), // retries left
                                __METHOD__
                        );
                        $ids = array_map( function( $o ) { return $o->job_id; 
}, iterator_to_array( $res ) );
@@ -453,7 +453,7 @@
                        "job_token_timestamp < {$dbw->addQuotes( $pruneCutoff 
)}" // stale
                );
                if ( $this->claimTTL > 0 ) { // only prune jobs attempted too 
many times...
-                       $conds[] = "job_attempts >= {$dbw->addQuotes( 
self::MAX_ATTEMPTS )}";
+                       $conds[] = "job_attempts >= {$dbw->addQuotes( 
$this->maxTries )}";
                }
                // Get the IDs of jobs that are considered stale and should be 
removed. Selecting
                // the IDs first means that the UPDATE can be done by primary 
key (less deadlocks).
diff --git a/includes/job/JobQueueRedis.php b/includes/job/JobQueueRedis.php
index 07a7410..2ce47bb 100644
--- a/includes/job/JobQueueRedis.php
+++ b/includes/job/JobQueueRedis.php
@@ -372,7 +372,7 @@
                                        if ( $ctime < $claimCutoff ) {
                                                // Get the number of failed 
attempts
                                                $attempts = isset( 
$info['attempts'] ) ? $info['attempts'] : 0;
-                                               if ( $attempts < 
self::MAX_ATTEMPTS ) {
+                                               if ( $attempts < 
$this->maxTries ) {
                                                        $uidsPush[] = $uid; // 
retry it
                                                } elseif ( $ctime < 
$pruneCutoff ) {
                                                        $uidsRemove[] = $uid; 
// just remove it

-- 
To view, visit https://gerrit.wikimedia.org/r/49960
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I3aaab748913af68f4a676855c5c4f825706f7be7
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: IAlex <ialex.w...@gmail.com>
Gerrit-Reviewer: MaxSem <maxsem.w...@gmail.com>
Gerrit-Reviewer: Parent5446 <tylerro...@gmail.com>
Gerrit-Reviewer: Tim Starling <tstarl...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to