X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fjob%2FJobQueueDB.php;h=56da4f3d8d6bb32308b955e582451841b6513d8d;hb=e7651f865d31dd6203828cf509383da2ea7515c3;hp=e8e03852af7e0e77c1f48b2e418b6382557cfedc;hpb=1bfc8feb25b564cc35ae1142271518a0c964f98d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/job/JobQueueDB.php b/includes/job/JobQueueDB.php index e8e03852af..56da4f3d8d 100644 --- a/includes/job/JobQueueDB.php +++ b/includes/job/JobQueueDB.php @@ -231,7 +231,7 @@ class JobQueueDB extends JobQueue { $method ); foreach ( $res as $row ) { - wfDebug( "Job with hash '{$row->job_sha1}' is a duplicate." ); + wfDebug( "Job with hash '{$row->job_sha1}' is a duplicate.\n" ); unset( $rowSet[$row->job_sha1] ); // already enqueued } } @@ -270,6 +270,11 @@ class JobQueueDB extends JobQueue { list( $dbw, $scope ) = $this->getMasterDB(); $dbw->commit( __METHOD__, 'flush' ); // flush existing transaction + $autoTrx = $dbw->getFlag( DBO_TRX ); // get current setting + $dbw->clearFlag( DBO_TRX ); // make each query its own transaction + $scopedReset = new ScopedCallback( function() use ( $dbw, $autoTrx ) { + $dbw->setFlag( $autoTrx ? DBO_TRX : 0 ); // restore old setting + } ); $uuid = wfRandomString( 32 ); // pop attempt $job = false; // job popped off @@ -292,7 +297,7 @@ class JobQueueDB extends JobQueue { $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, @@ -434,7 +439,7 @@ class JobQueueDB extends JobQueue { 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 @@ -457,6 +462,11 @@ class JobQueueDB extends JobQueue { list( $dbw, $scope ) = $this->getMasterDB(); $dbw->commit( __METHOD__, 'flush' ); // flush existing transaction + $autoTrx = $dbw->getFlag( DBO_TRX ); // get current setting + $dbw->clearFlag( DBO_TRX ); // make each query its own transaction + $scopedReset = new ScopedCallback( function() use ( $dbw, $autoTrx ) { + $dbw->setFlag( $autoTrx ? DBO_TRX : 0 ); // restore old setting + } ); // Delete a row with a single DELETE without holding row locks over RTTs... $dbw->delete( 'job', @@ -499,6 +509,17 @@ class JobQueueDB extends JobQueue { return true; } + /** + * @see JobQueue::doDelete() + * @return bool + */ + protected function doDelete() { + list( $dbw, $scope ) = $this->getMasterDB(); + + $dbw->delete( 'job', array( 'job_cmd' => $this->type ) ); + return true; + } + /** * @see JobQueue::doWaitForBackups() * @return void @@ -689,7 +710,8 @@ class JobQueueDB extends JobQueue { */ 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 ); } /**