Merge "[JobQueue] Use regular wfDebug() in some places."
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 24 Apr 2013 18:46:57 +0000 (18:46 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 24 Apr 2013 18:46:57 +0000 (18:46 +0000)
1  2 
includes/job/JobQueueDB.php

@@@ -225,7 -225,7 +225,7 @@@ class JobQueueDB extends JobQueue 
                                $res = $dbw->select( 'job', 'job_sha1',
                                        array(
                                                // No job_type condition since it's part of the job_sha1 hash
 -                                              'job_sha1'  => array_keys( $rowSet ),
 +                                              'job_sha1' => array_keys( $rowSet ),
                                                'job_token' => '' // unclaimed
                                        ),
                                        $method
                        $title = Title::makeTitleSafe( $row->job_namespace, $row->job_title );
                        if ( !$title ) {
                                $dbw->delete( 'job', array( 'job_id' => $row->job_id ), __METHOD__ );
-                               wfDebugLog( 'JobQueueDB', "Row has invalid title '{$row->job_title}'." );
+                               wfDebug( "Row has invalid title '{$row->job_title}'." );
                                continue; // try again
                        }
                        $job = Job::factory( $row->job_cmd, $title,
                        $job->metadata['id'] = $row->job_id;
                        $job->id = $row->job_id; // XXX: work around broken subclasses
                        break; // done
 -              } while( true );
 +              } while ( true );
  
                return $job;
        }
                                $dir = $gte ? 'ASC' : 'DESC';
                                $row = $dbw->selectRow( 'job', '*', // find a random job
                                        array(
 -                                              'job_cmd'   => $this->type,
 +                                              'job_cmd' => $this->type,
                                                'job_token' => '', // unclaimed
                                                "job_random {$ineq} {$dbw->addQuotes( $rand )}" ),
                                        __METHOD__,
                                // instead of job_random for reducing excess claim retries.
                                $row = $dbw->selectRow( 'job', '*', // find a random job
                                        array(
 -                                              'job_cmd'   => $this->type,
 +                                              'job_cmd' => $this->type,
                                                'job_token' => '', // unclaimed
                                        ),
                                        __METHOD__,
                        if ( $row ) { // claim the job
                                $dbw->update( 'job', // update by PK
                                        array(
 -                                              'job_token'           => $uuid,
 +                                              'job_token' => $uuid,
                                                'job_token_timestamp' => $dbw->timestamp(),
                                                'job_attempts = job_attempts+1' ),
                                        array( 'job_cmd' => $this->type, 'job_id' => $row->job_id, 'job_token' => '' ),
                                // This uses as much of the DB wrapper functions as possible.
                                $dbw->update( 'job',
                                        array(
 -                                              'job_token'           => $uuid,
 +                                              'job_token' => $uuid,
                                                'job_token_timestamp' => $dbw->timestamp(),
                                                'job_attempts = job_attempts+1' ),
                                        array( 'job_id = (' .
                                        array( 'job_cmd' => $this->type, 'job_token' => $uuid ), __METHOD__
                                );
                                if ( !$row ) { // raced out by duplicate job removal
-                                       wfDebugLog( 'JobQueueDB', "Row deleted as duplicate by another process." );
+                                       wfDebug( "Row deleted as duplicate by another process." );
                                }
                        } else {
                                break; // nothing to do
                return array(
                        'recycleAndDeleteStaleJobs' => array(
                                'callback' => array( $this, 'recycleAndDeleteStaleJobs' ),
 -                              'period'   => ceil( $this->claimTTL / 2 )
 +                              'period' => ceil( $this->claimTTL / 2 )
                        )
                );
        }
                                        "job_attempts < {$dbw->addQuotes( $this->maxTries )}" ), // retries left
                                __METHOD__
                        );
 -                      $ids = array_map( function( $o ) { return $o->job_id; }, iterator_to_array( $res ) );
 +                      $ids = array_map(
 +                              function( $o ) {
 +                                      return $o->job_id;
 +                              }, iterator_to_array( $res )
 +                      );
                        if ( count( $ids ) ) {
                                // Reset job_token for these jobs so that other runners will pick them up.
                                // Set the timestamp to the current time, as it is useful to now that the job
                // 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).
                $res = $dbw->select( 'job', 'job_id', $conds, __METHOD__ );
 -              $ids = array_map( function( $o ) { return $o->job_id; }, iterator_to_array( $res ) );
 +              $ids = array_map(
 +                      function( $o ) {
 +                              return $o->job_id;
 +                      }, iterator_to_array( $res )
 +              );
                if ( count( $ids ) ) {
                        $dbw->delete( 'job', array( 'job_id' => $ids ), __METHOD__ );
                        $count += $dbw->affectedRows();
         */
        private function getCacheKey( $property ) {
                list( $db, $prefix ) = wfSplitWikiID( $this->wiki );
 -              return wfForeignMemcKey( $db, $prefix, 'jobqueue', $this->type, $property );
 +              $cluster = is_string( $this->cluster ) ? $this->cluster : 'main';
 +              return wfForeignMemcKey( $db, $prefix, 'jobqueue', $cluster, $this->type, $property );
        }
  
        /**