From: Andrew Garrett Date: Mon, 21 Sep 2009 16:15:07 +0000 (+0000) Subject: Use unbuffered queries in cleanupTable maintenance scripts. Prevents OOM issues. X-Git-Tag: 1.31.0-rc.0~39594 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=commitdiff_plain;h=0c3b59f0c476cb7c6e33a6407c151653c69cb85a;p=lhc%2Fweb%2Fwiklou.git Use unbuffered queries in cleanupTable maintenance scripts. Prevents OOM issues. --- diff --git a/maintenance/cleanupTable.inc b/maintenance/cleanupTable.inc index 80be0557fe..ef5bebdd7a 100644 --- a/maintenance/cleanupTable.inc +++ b/maintenance/cleanupTable.inc @@ -87,6 +87,10 @@ abstract class TableCleanup extends Maintenance { protected function runTable( $table, $where, $callback ) { $dbw = wfGetDB( DB_MASTER ); + + // Unbuffered queries, avoids OOM + $dbw->bufferResults( false ); + $count = $dbw->selectField( $table, 'count(*)', '', __METHOD__ ); $this->init( $count, $table ); $this->output( "Processing $table..." ); @@ -98,8 +102,12 @@ abstract class TableCleanup extends Maintenance { foreach( $result as $row ) { call_user_func( $callback, $row ); } + $this->output( "Finished $table... $this->updated of $this->processed rows updated\n" ); + $result->free(); + + $dbw->bufferResults( true ); } protected function hexChar( $matches ) {