Pass a limit to BackLinkCache::getNumLinks() in some places to avoid OOMs.
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 18 Apr 2013 18:29:20 +0000 (11:29 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 18 Apr 2013 18:29:26 +0000 (11:29 -0700)
Change-Id: Idf1042c083837a9e4a380bb20ecdf3043ea9ab09

includes/job/jobs/HTMLCacheUpdateJob.php
includes/job/jobs/RefreshLinksJob.php

index 1a2143e..376b388 100644 (file)
@@ -82,7 +82,8 @@ class HTMLCacheUpdateJob extends Job {
                global $wgMaxBacklinksInvalidate;
 
                # Get an estimate of the number of rows from the BacklinkCache
-               $numRows = $this->blCache->getNumLinks( $this->params['table'] );
+               $max = max( $this->rowsPerJob * 2, $wgMaxBacklinksInvalidate ) + 1;
+               $numRows = $this->blCache->getNumLinks( $this->params['table'], $max );
                if ( $wgMaxBacklinksInvalidate !== false && $numRows > $wgMaxBacklinksInvalidate ) {
                        wfDebug( "Skipped HTML cache invalidation of {$this->title->getPrefixedText()}." );
                        return true;
index 9dbe827..2ba855d 100644 (file)
@@ -158,7 +158,7 @@ class RefreshLinksJob2 extends Job {
                        $jobs = array_merge( $jobs, $this->getSingleTitleJobs( $table, $masterPos ) );
                } else {
                        # This is a base job to trigger the insertion of partitioned jobs...
-                       if ( $tbc->getNumLinks( $table ) <= $wgUpdateRowsPerJob ) {
+                       if ( $tbc->getNumLinks( $table, $wgUpdateRowsPerJob + 1 ) <= $wgUpdateRowsPerJob ) {
                                # Just directly insert the single per-title jobs
                                $jobs = array_merge( $jobs, $this->getSingleTitleJobs( $table, $masterPos ) );
                        } else {