Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/227249

Change subject: populateContentModel: Clear LinkCache occasionally
......................................................................

populateContentModel: Clear LinkCache occasionally

Work around T106998 for now.

Change-Id: If217ca07c865aafa0b8bab24e27e39c7ea601e76
---
M maintenance/populateContentModel.php
1 file changed, 19 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/49/227249/1

diff --git a/maintenance/populateContentModel.php 
b/maintenance/populateContentModel.php
index 3f5d6b6..fd2692a 100644
--- a/maintenance/populateContentModel.php
+++ b/maintenance/populateContentModel.php
@@ -28,6 +28,13 @@
  *  populateContentModel.php --ns=1 --table=page
  */
 class PopulateContentModel extends Maintenance {
+
+       /**
+        * Clear the LinkCache after processing this many rows
+        * to avoid OOMs (T106998)
+        */
+       const CLEAR_LINK_CACHE = 500;
+
        public function __construct() {
                parent::__construct();
                $this->mDescription = 'Populate the various content_* fields';
@@ -74,6 +81,7 @@
                $toSave = array();
                $lastId = 0;
                $nsCondition = $ns === 'all' ? array() : array( 
'page_namespace' => $ns );
+               $count = 0;
                do {
                        $rows = $dbw->select(
                                'page',
@@ -95,6 +103,10 @@
                                        unset( $toSave[$model] );
                                }
                                $lastId = $row->page_id;
+                               $count++;
+                               if ( $count >= self::CLEAR_LINK_CACHE ) {
+                                       LinkCache::singleton()->clear();
+                               }
                        }
                } while ( $rows->numRows() >= $this->mBatchSize );
                foreach ( $toSave as $model => $pages ) {
@@ -139,6 +151,7 @@
 
                $toSave = array();
                $lastId = 0;
+               $count = 0;
                do {
                        $rows = $dbw->select(
                                $selectTables,
@@ -161,6 +174,7 @@
                                }
                                $lastId = $row->{$key};
                                try {
+                                       // FIXME this should use 
ContentHandler::getDefaultModelFor()
                                        $handler = ContentHandler::getForTitle( 
$title );
                                } catch ( MWException $e ) {
                                        $this->error( "Invalid content model 
for $title" );
@@ -195,6 +209,11 @@
                                        $this->updateRevisionOrArchiveRows( 
$dbw, $toSave[$defaultModel], $defaultModel, $table );
                                        unset( $toSave[$defaultModel] );
                                }
+
+                               $count++;
+                               if ( $count > self::CLEAR_LINK_CACHE ) {
+                                       LinkCache::singleton()->clear();
+                               }
                        }
                } while ( $rows->numRows() >= $this->mBatchSize );
                foreach ( $toSave as $model => $ids ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/227249
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If217ca07c865aafa0b8bab24e27e39c7ea601e76
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to