Make JobQueueAggregator::doNotifyQueueNonEmpty() avoid queries
[lhc/web/wiklou.git] / includes / jobqueue / JobRunner.php
index 700a63d..dd2ef8f 100644 (file)
@@ -191,17 +191,27 @@ class JobRunner implements LoggerAwareInterface {
                                }
                                // Commit all outstanding connections that are in a transaction
                                // to get a fresh repeatable read snapshot on every connection.
+                               // Note that jobs are still responsible for handling slave lag.
                                wfGetLBFactory()->commitAll();
+                               // Clear out title cache data from prior snapshots
+                               LinkCache::singleton()->clear();
                                $timeMs = intval( ( microtime( true ) - $jobStartTime ) * 1000 );
                                $timeMsTotal += $timeMs;
 
+                               // Record how long jobs wait before getting popped
                                $readyTs = $job->getReadyTimestamp();
                                if ( $readyTs ) {
-                                       // Record time to run for the job type
                                        $pickupDelay = $popTime - $readyTs;
                                        $stats->timing( 'jobqueue.pickup_delay.all', 1000 * $pickupDelay );
                                        $stats->timing( "jobqueue.pickup_delay.$jType", 1000 * $pickupDelay );
                                }
+                               // Record root job age for jobs being run
+                               $root = $job->getRootJobParams();
+                               if ( $root['rootJobTimestamp'] ) {
+                                       $age = $popTime - wfTimestamp( TS_UNIX, $root['rootJobTimestamp'] );
+                                       $stats->timing( "jobqueue.pickup_root_age.$jType", 1000 * $age );
+                               }
+                               // Track the execution time for jobs
                                $stats->timing( "jobqueue.run.$jType", $timeMs );
 
                                // Mark the job as done on success or when the job cannot be retried
@@ -460,7 +470,7 @@ class JobRunner implements LoggerAwareInterface {
 
                $ms = intval( 1000 * $dbwSerial->pendingWriteQueryDuration() );
                $msg = $job->toString() . " COMMIT ENQUEUED [{$ms}ms of writes]";
-               $this->logger->info( $msg );
+               $this->logger->warning( $msg );
                $this->debugCallback( $msg );
 
                // Wait for an exclusive lock to commit
@@ -478,7 +488,7 @@ class JobRunner implements LoggerAwareInterface {
                // Re-ping all masters with transactions. This throws DBError if some
                // connection died while waiting on locks/slaves, triggering a rollback.
                wfGetLBFactory()->forEachLB( function( LoadBalancer $lb ) use ( $fname ) {
-                       $lb->forEachOpenConnection( function( DatabaseBase $conn ) use ( $fname ) {
+                       $lb->forEachOpenConnection( function( IDatabase $conn ) use ( $fname ) {
                                if ( $conn->writesOrCallbacksPending() ) {
                                        $conn->query( "SELECT 1", $fname );
                                }