r83531 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83530‎ | r83531 | r83532 >
Date:17:21, 8 March 2011
Author:catrope
Status:ok
Tags:
Comment:
1.17wmf1: MFT r83529
Modified paths:
  • /branches/wmf/1.17wmf1/includes/db/LoadBalancer.php (modified) (history)
  • /branches/wmf/1.17wmf1/maintenance/updateCollation.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/maintenance/updateCollation.php
@@ -26,9 +26,16 @@
2727 $this->addOption( 'force', 'Run on all rows, even if the collation is ' .
2828 'supposed to be up-to-date.' );
2929 }
 30+
 31+ public function syncDBs() {
 32+ $lb = wfGetLB();
 33+ $dbw = $lb->getConnection( DB_MASTER );
 34+ $pos = $dbw->getMasterPos();
 35+ $lb->waitForAll( $pos );
 36+ }
3037
3138 public function execute() {
32 - global $wgCategoryCollation;
 39+ global $wgCategoryCollation, $wgMiserMode;
3340
3441 $dbw = wfGetDB( DB_MASTER );
3542 $force = $this->getOption( 'force' );
@@ -36,30 +43,32 @@
3744 $options = array( 'LIMIT' => self::BATCH_SIZE );
3845
3946 if ( $force ) {
40 - $collationConds = array();
4147 $options['ORDER BY'] = 'cl_from, cl_to';
4248 } else {
4349 $collationConds = array( 0 =>
4450 'cl_collation != ' . $dbw->addQuotes( $wgCategoryCollation ) );
4551
46 - $count = $dbw->selectField(
47 - 'categorylinks',
48 - 'COUNT(*)',
49 - $collationConds,
50 - __METHOD__
51 - );
 52+ if ( !$wgMiserMode ) {
 53+ $count = $dbw->selectField(
 54+ 'categorylinks',
 55+ 'COUNT(*)',
 56+ $collationConds,
 57+ __METHOD__
 58+ );
5259
53 - if ( $count == 0 ) {
54 - $this->output( "Collations up-to-date.\n" );
55 - return;
 60+ if ( $count == 0 ) {
 61+ $this->output( "Collations up-to-date.\n" );
 62+ return;
 63+ }
 64+ $this->output( "Fixing collation for $count rows.\n" );
5665 }
57 - $this->output( "Fixing collation for $count rows.\n" );
5866 }
5967
6068 $count = 0;
6169 $row = false;
6270 $batchConds = array();
6371 do {
 72+ $this->output( 'Processing next ' . self::BATCH_SIZE . ' rows... ');
6473 $res = $dbw->select(
6574 array( 'categorylinks', 'page' ),
6675 array( 'cl_from', 'cl_to', 'cl_sortkey_prefix', 'cl_collation',
@@ -121,6 +130,8 @@
122131
123132 $count += $res->numRows();
124133 $this->output( "$count done.\n" );
 134+
 135+ $this->syncDBs();
125136 } while ( $res->numRows() == self::BATCH_SIZE );
126137 }
127138 }
Index: branches/wmf/1.17wmf1/includes/db/LoadBalancer.php
@@ -338,6 +338,18 @@
339339 }
340340 wfProfileOut( __METHOD__ );
341341 }
 342+
 343+ /**
 344+ * Set the master wait position and wait for ALL slaves to catch up to it
 345+ */
 346+ public function waitForAll( $pos ) {
 347+ wfProfileIn( __METHOD__ );
 348+ $this->mWaitForPos = $pos;
 349+ for ( $i = 1; $i < count( $this->mServers ); $i++ ) {
 350+ $this->doWait( $i );
 351+ }
 352+ wfProfileOut( __METHOD__ );
 353+ }
342354
343355 /**
344356 * Get any open connection to a given server index, local or foreign

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r83529Make updateCollation.php a bit less murderous for WMF databases:...catrope16:47, 8 March 2011

Status & tagging log