Index: trunk/phase3/maintenance/runBatchedQuery.php |
— | — | @@ -29,7 +29,6 @@ |
30 | 30 | parent::__construct(); |
31 | 31 | $this->mDescription = "Run a query repeatedly until it affects 0 rows, and wait for slaves in between.\n" . |
32 | 32 | "NOTE: You need to set a LIMIT clause yourself."; |
33 | | - $this->addOption( 'wait', "Wait for replication lag to go down to this value. Default: 5", false, true ); |
34 | 33 | } |
35 | 34 | |
36 | 35 | public function execute() { |
— | — | @@ -46,7 +45,7 @@ |
47 | 46 | $dbw->query( $query, __METHOD__ ); |
48 | 47 | $affected = $dbw->affectedRows(); |
49 | 48 | $this->output( "$affected rows\n" ); |
50 | | - wfWaitForSlaves( $wait ); |
| 49 | + wfWaitForSlaves_masterPos(); |
51 | 50 | } while ( $affected > 0 ); |
52 | 51 | } |
53 | 52 | |
Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -3178,6 +3178,22 @@ |
3179 | 3179 | } |
3180 | 3180 | |
3181 | 3181 | /** |
| 3182 | + * Modern version of wfWaitForSlaves(). Instead of looking at replication lag |
| 3183 | + * and waiting for it to go down, this waits for the slaves to catch up to the |
| 3184 | + * master position. This is much better for lag control than wfWaitForSlaves() |
| 3185 | + */ |
| 3186 | +function wfWaitForSlaves_masterPos() { |
| 3187 | + $lb = wfGetLB(); |
| 3188 | + // bug 27975 - Don't try to wait for slaves if there are none |
| 3189 | + // Prevents permission error when getting master position |
| 3190 | + if ( $lb->getServerCount() > 1 ) { |
| 3191 | + $dbw = $lb->getConnection( DB_MASTER ); |
| 3192 | + $pos = $dbw->getMasterPos(); |
| 3193 | + $lb->waitForAll( $pos ); |
| 3194 | + } |
| 3195 | +} |
| 3196 | + |
| 3197 | +/** |
3182 | 3198 | * Used to be used for outputting text in the installer/updater |
3183 | 3199 | * @deprecated Warnings in 1.19, removal in 1.20 |
3184 | 3200 | */ |