From: Andrew Garrett Date: Mon, 21 Sep 2009 17:34:24 +0000 (+0000) Subject: Use slave for unbuffered reading in cleanupTable.inc, leaving the master for buffered... X-Git-Tag: 1.31.0-rc.0~39591 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=0cbbed0f803cfc4adb3930d5c4a17adae75090f2;p=lhc%2Fweb%2Fwiklou.git Use slave for unbuffered reading in cleanupTable.inc, leaving the master for buffered writing --- diff --git a/maintenance/cleanupTable.inc b/maintenance/cleanupTable.inc index 986a44e19d..f67b3b1b64 100644 --- a/maintenance/cleanupTable.inc +++ b/maintenance/cleanupTable.inc @@ -86,18 +86,18 @@ abstract class TableCleanup extends Maintenance { } protected function runTable( $table, $where, $callback ) { - $dbw = wfGetDB( DB_MASTER ); + $dbr = wfGetDB( DB_SLAVE ); - $count = $dbw->selectField( $table, 'count(*)', '', __METHOD__ ); + $count = $dbr->selectField( $table, 'count(*)', '', __METHOD__ ); $this->init( $count, $table ); $this->output( "Processing $table..." ); // Unbuffered queries, avoids OOM - $dbw->bufferResults( false ); + $dbr->bufferResults( false ); - $tableName = $dbw->tableName( $table ); + $tableName = $dbr->tableName( $table ); $sql = "SELECT * FROM $tableName $where"; - $result = $dbw->query( $sql, __METHOD__ ); + $result = $dbr->query( $sql, __METHOD__ ); foreach( $result as $row ) { call_user_func( $callback, $row ); @@ -107,7 +107,7 @@ abstract class TableCleanup extends Maintenance { $result->free(); - $dbw->bufferResults( true ); + $dbr->bufferResults( true ); } protected function hexChar( $matches ) {