From 97b66aef1728ba9f978dc55411a9400cd86b9b2f Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 18 Apr 2013 11:29:20 -0700 Subject: [PATCH] Pass a limit to BackLinkCache::getNumLinks() in some places to avoid OOMs. Change-Id: Idf1042c083837a9e4a380bb20ecdf3043ea9ab09 --- includes/job/jobs/HTMLCacheUpdateJob.php | 3 ++- includes/job/jobs/RefreshLinksJob.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/job/jobs/HTMLCacheUpdateJob.php b/includes/job/jobs/HTMLCacheUpdateJob.php index 1a2143e315..376b3884af 100644 --- a/includes/job/jobs/HTMLCacheUpdateJob.php +++ b/includes/job/jobs/HTMLCacheUpdateJob.php @@ -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; diff --git a/includes/job/jobs/RefreshLinksJob.php b/includes/job/jobs/RefreshLinksJob.php index 9dbe82786f..2ba855dd2c 100644 --- a/includes/job/jobs/RefreshLinksJob.php +++ b/includes/job/jobs/RefreshLinksJob.php @@ -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 { -- 2.20.1