Index: trunk/phase3/maintenance/updateCollation.php |
— | — | @@ -45,9 +45,16 @@ |
46 | 46 | $this->addOption( 'force', 'Run on all rows, even if the collation is ' . |
47 | 47 | 'supposed to be up-to-date.' ); |
48 | 48 | } |
| 49 | + |
| 50 | + public function syncDBs() { |
| 51 | + $lb = wfGetLB(); |
| 52 | + $dbw = $lb->getConnection( DB_MASTER ); |
| 53 | + $pos = $dbw->getMasterPos(); |
| 54 | + $lb->waitForAll( $pos ); |
| 55 | + } |
49 | 56 | |
50 | 57 | public function execute() { |
51 | | - global $wgCategoryCollation; |
| 58 | + global $wgCategoryCollation, $wgMiserMode; |
52 | 59 | |
53 | 60 | $dbw = wfGetDB( DB_MASTER ); |
54 | 61 | $force = $this->getOption( 'force' ); |
— | — | @@ -55,30 +62,32 @@ |
56 | 63 | $options = array( 'LIMIT' => self::BATCH_SIZE ); |
57 | 64 | |
58 | 65 | if ( $force ) { |
59 | | - $collationConds = array(); |
60 | 66 | $options['ORDER BY'] = 'cl_from, cl_to'; |
61 | 67 | } else { |
62 | 68 | $collationConds = array( 0 => |
63 | 69 | 'cl_collation != ' . $dbw->addQuotes( $wgCategoryCollation ) ); |
64 | 70 | |
65 | | - $count = $dbw->selectField( |
66 | | - 'categorylinks', |
67 | | - 'COUNT(*)', |
68 | | - $collationConds, |
69 | | - __METHOD__ |
70 | | - ); |
| 71 | + if ( !$wgMiserMode ) { |
| 72 | + $count = $dbw->selectField( |
| 73 | + 'categorylinks', |
| 74 | + 'COUNT(*)', |
| 75 | + $collationConds, |
| 76 | + __METHOD__ |
| 77 | + ); |
71 | 78 | |
72 | | - if ( $count == 0 ) { |
73 | | - $this->output( "Collations up-to-date.\n" ); |
74 | | - return; |
| 79 | + if ( $count == 0 ) { |
| 80 | + $this->output( "Collations up-to-date.\n" ); |
| 81 | + return; |
| 82 | + } |
| 83 | + $this->output( "Fixing collation for $count rows.\n" ); |
75 | 84 | } |
76 | | - $this->output( "Fixing collation for $count rows.\n" ); |
77 | 85 | } |
78 | 86 | |
79 | 87 | $count = 0; |
80 | 88 | $row = false; |
81 | 89 | $batchConds = array(); |
82 | 90 | do { |
| 91 | + $this->output( 'Processing next ' . self::BATCH_SIZE . ' rows... '); |
83 | 92 | $res = $dbw->select( |
84 | 93 | array( 'categorylinks', 'page' ), |
85 | 94 | array( 'cl_from', 'cl_to', 'cl_sortkey_prefix', 'cl_collation', |
— | — | @@ -140,6 +149,8 @@ |
141 | 150 | |
142 | 151 | $count += $res->numRows(); |
143 | 152 | $this->output( "$count done.\n" ); |
| 153 | + |
| 154 | + $this->syncDBs(); |
144 | 155 | } while ( $res->numRows() == self::BATCH_SIZE ); |
145 | 156 | } |
146 | 157 | } |
Index: trunk/phase3/includes/db/LoadBalancer.php |
— | — | @@ -338,6 +338,18 @@ |
339 | 339 | } |
340 | 340 | wfProfileOut( __METHOD__ ); |
341 | 341 | } |
| 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 | + } |
342 | 354 | |
343 | 355 | /** |
344 | 356 | * Get any open connection to a given server index, local or foreign |