Index: branches/wmf/1.17wmf1/maintenance/updateCollation.php |
— | — | @@ -26,9 +26,16 @@ |
27 | 27 | $this->addOption( 'force', 'Run on all rows, even if the collation is ' . |
28 | 28 | 'supposed to be up-to-date.' ); |
29 | 29 | } |
| 30 | + |
| 31 | + public function syncDBs() { |
| 32 | + $lb = wfGetLB(); |
| 33 | + $dbw = $lb->getConnection( DB_MASTER ); |
| 34 | + $pos = $dbw->getMasterPos(); |
| 35 | + $lb->waitForAll( $pos ); |
| 36 | + } |
30 | 37 | |
31 | 38 | public function execute() { |
32 | | - global $wgCategoryCollation; |
| 39 | + global $wgCategoryCollation, $wgMiserMode; |
33 | 40 | |
34 | 41 | $dbw = wfGetDB( DB_MASTER ); |
35 | 42 | $force = $this->getOption( 'force' ); |
— | — | @@ -36,30 +43,32 @@ |
37 | 44 | $options = array( 'LIMIT' => self::BATCH_SIZE ); |
38 | 45 | |
39 | 46 | if ( $force ) { |
40 | | - $collationConds = array(); |
41 | 47 | $options['ORDER BY'] = 'cl_from, cl_to'; |
42 | 48 | } else { |
43 | 49 | $collationConds = array( 0 => |
44 | 50 | 'cl_collation != ' . $dbw->addQuotes( $wgCategoryCollation ) ); |
45 | 51 | |
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 | + ); |
52 | 59 | |
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" ); |
56 | 65 | } |
57 | | - $this->output( "Fixing collation for $count rows.\n" ); |
58 | 66 | } |
59 | 67 | |
60 | 68 | $count = 0; |
61 | 69 | $row = false; |
62 | 70 | $batchConds = array(); |
63 | 71 | do { |
| 72 | + $this->output( 'Processing next ' . self::BATCH_SIZE . ' rows... '); |
64 | 73 | $res = $dbw->select( |
65 | 74 | array( 'categorylinks', 'page' ), |
66 | 75 | array( 'cl_from', 'cl_to', 'cl_sortkey_prefix', 'cl_collation', |
— | — | @@ -121,6 +130,8 @@ |
122 | 131 | |
123 | 132 | $count += $res->numRows(); |
124 | 133 | $this->output( "$count done.\n" ); |
| 134 | + |
| 135 | + $this->syncDBs(); |
125 | 136 | } while ( $res->numRows() == self::BATCH_SIZE ); |
126 | 137 | } |
127 | 138 | } |
Index: branches/wmf/1.17wmf1/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 |