Index: trunk/phase3/maintenance/runBatchedQuery.php |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | $dbw->query( $query, __METHOD__ ); |
47 | 47 | $affected = $dbw->affectedRows(); |
48 | 48 | $this->output( "$affected rows\n" ); |
49 | | - wfWaitForSlaves_masterPos(); |
| 49 | + wfWaitForSlaves(); |
50 | 50 | } while ( $affected > 0 ); |
51 | 51 | } |
52 | 52 | |
Index: trunk/phase3/maintenance/archives/upgradeLogging.php |
— | — | @@ -164,7 +164,7 @@ |
165 | 165 | $this->dbw->insert( $dstTable, $batch, __METHOD__ ); |
166 | 166 | $numRowsCopied += count( $batch ); |
167 | 167 | |
168 | | - wfWaitForSlaves( 5 ); |
| 168 | + wfWaitForSlaves(); |
169 | 169 | } |
170 | 170 | echo "Copied $numRowsCopied rows\n"; |
171 | 171 | } |
Index: trunk/phase3/maintenance/storage/fixBug20757.php |
— | — | @@ -260,7 +260,7 @@ |
261 | 261 | static $iteration = 0; |
262 | 262 | ++$iteration; |
263 | 263 | if ( ++$iteration > 50 == 0 ) { |
264 | | - wfWaitForSlaves( 5 ); |
| 264 | + wfWaitForSlaves(); |
265 | 265 | $iteration = 0; |
266 | 266 | } |
267 | 267 | } |
Index: trunk/phase3/maintenance/storage/compressOld.inc |
— | — | @@ -155,7 +155,7 @@ |
156 | 156 | #$conds[] = 'page_id=rev_page AND rev_id != page_latest'; |
157 | 157 | |
158 | 158 | for ( $pageId = $startId; $pageId <= $maxPageId; $pageId++ ) { |
159 | | - wfWaitForSlaves( 5 ); |
| 159 | + wfWaitForSlaves(); |
160 | 160 | |
161 | 161 | # Wake up |
162 | 162 | $dbr->ping(); |
— | — | @@ -309,7 +309,7 @@ |
310 | 310 | print "/"; |
311 | 311 | $dbw->commit(); |
312 | 312 | $i += $thisChunkSize; |
313 | | - wfWaitForSlaves( 5 ); |
| 313 | + wfWaitForSlaves(); |
314 | 314 | } |
315 | 315 | print "\n"; |
316 | 316 | } |
Index: trunk/phase3/maintenance/storage/moveToExternal.php |
— | — | @@ -66,7 +66,7 @@ |
67 | 67 | |
68 | 68 | if ( !( $block % REPORTING_INTERVAL ) ) { |
69 | 69 | print "oldid=$blockStart, moved=$numMoved\n"; |
70 | | - wfWaitForSlaves( 2 ); |
| 70 | + wfWaitForSlaves(); |
71 | 71 | } |
72 | 72 | |
73 | 73 | $res = $dbr->select( 'text', array( 'old_id', 'old_flags', 'old_text' ), |
Index: trunk/phase3/maintenance/storage/resolveStubs.php |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | $numBlocks = intval( $maxID / $blockSize ) + 1; |
47 | 47 | |
48 | 48 | for ( $b = 0; $b < $numBlocks; $b++ ) { |
49 | | - wfWaitForSlaves( 2 ); |
| 49 | + wfWaitForSlaves(); |
50 | 50 | |
51 | 51 | printf( "%5.2f%%\n", $b / $numBlocks * 100 ); |
52 | 52 | $start = intval( $maxID / $numBlocks ) * $b + 1; |
Index: trunk/phase3/maintenance/storage/trackBlobs.php |
— | — | @@ -206,7 +206,7 @@ |
207 | 207 | if ( $batchesDone >= $this->reportingInterval ) { |
208 | 208 | $batchesDone = 0; |
209 | 209 | echo "$startId / $endId\n"; |
210 | | - wfWaitForSlaves( 5 ); |
| 210 | + wfWaitForSlaves(); |
211 | 211 | } |
212 | 212 | } |
213 | 213 | echo "Found $rowsInserted revisions\n"; |
— | — | @@ -290,7 +290,7 @@ |
291 | 291 | if ( $batchesDone >= $this->reportingInterval ) { |
292 | 292 | $batchesDone = 0; |
293 | 293 | echo "$startId / $endId\n"; |
294 | | - wfWaitForSlaves( 5 ); |
| 294 | + wfWaitForSlaves(); |
295 | 295 | } |
296 | 296 | } |
297 | 297 | echo "Found $rowsInserted orphan text rows\n"; |
Index: trunk/phase3/maintenance/populateSha1.php |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | foreach ( $res as $row ) { |
70 | 70 | if ( $i % 100 == 0 ) { |
71 | 71 | $this->output( sprintf( "Done %d of %d, %5.3f%% \r", $i, $numRows, $i / $numRows * 100 ) ); |
72 | | - wfWaitForSlaves( 5 ); |
| 72 | + wfWaitForSlaves(); |
73 | 73 | } |
74 | 74 | $file = wfLocalFile( $row->img_name ); |
75 | 75 | if ( !$file ) { |
Index: trunk/phase3/maintenance/rebuildFileCache.php |
— | — | @@ -109,7 +109,7 @@ |
110 | 110 | } |
111 | 111 | $blockStart += $this->mBatchSize; |
112 | 112 | $blockEnd += $this->mBatchSize; |
113 | | - wfWaitForSlaves( 5 ); |
| 113 | + wfWaitForSlaves(); |
114 | 114 | } |
115 | 115 | $this->output( "Done!\n" ); |
116 | 116 | |
Index: trunk/phase3/maintenance/refreshLinks.php |
— | — | @@ -107,7 +107,7 @@ |
108 | 108 | foreach ( $res as $row ) { |
109 | 109 | if ( !( ++$i % $reportingInterval ) ) { |
110 | 110 | $this->output( "$i\n" ); |
111 | | - wfWaitForSlaves( $maxLag ); |
| 111 | + wfWaitForSlaves(); |
112 | 112 | } |
113 | 113 | $this->fixRedirect( $row->page_id ); |
114 | 114 | } |
— | — | @@ -127,7 +127,7 @@ |
128 | 128 | foreach ( $res as $row ) { |
129 | 129 | if ( !( ++$i % $reportingInterval ) ) { |
130 | 130 | $this->output( "$i\n" ); |
131 | | - wfWaitForSlaves( $maxLag ); |
| 131 | + wfWaitForSlaves(); |
132 | 132 | } |
133 | 133 | if ( $redirectsOnly ) { |
134 | 134 | $this->fixRedirect( $row->page_id ); |
— | — | @@ -148,7 +148,7 @@ |
149 | 149 | |
150 | 150 | if ( !( $id % $reportingInterval ) ) { |
151 | 151 | $this->output( "$id\n" ); |
152 | | - wfWaitForSlaves( $maxLag ); |
| 152 | + wfWaitForSlaves(); |
153 | 153 | } |
154 | 154 | $this->fixRedirect( $id ); |
155 | 155 | } |
— | — | @@ -161,7 +161,7 @@ |
162 | 162 | |
163 | 163 | if ( !( $id % $reportingInterval ) ) { |
164 | 164 | $this->output( "$id\n" ); |
165 | | - wfWaitForSlaves( $maxLag ); |
| 165 | + wfWaitForSlaves(); |
166 | 166 | } |
167 | 167 | self::fixLinksFromArticle( $id ); |
168 | 168 | } |
— | — | @@ -237,7 +237,7 @@ |
238 | 238 | * @author Merlijn van Deen <valhallasw@arctus.nl> |
239 | 239 | */ |
240 | 240 | private function deleteLinksFromNonexistent( $maxLag = 0, $batchSize = 100 ) { |
241 | | - wfWaitForSlaves( $maxLag ); |
| 241 | + wfWaitForSlaves(); |
242 | 242 | |
243 | 243 | $dbw = wfGetDB( DB_MASTER ); |
244 | 244 | |
— | — | @@ -273,7 +273,7 @@ |
274 | 274 | $counter++; |
275 | 275 | $list[] = $row->$field; |
276 | 276 | if ( ( $counter % $batchSize ) == 0 ) { |
277 | | - wfWaitForSlaves( 5 ); |
| 277 | + wfWaitForSlaves(); |
278 | 278 | $dbw->delete( $table, array( $field => $list ), __METHOD__ ); |
279 | 279 | |
280 | 280 | $this->output( $counter . ".." ); |
Index: trunk/phase3/maintenance/deleteSelfExternals.php |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | $this->output( "Deleting self externals from $wgServer\n" ); |
41 | 41 | $db = wfGetDB( DB_MASTER ); |
42 | 42 | while ( 1 ) { |
43 | | - wfWaitForSlaves( 2 ); |
| 43 | + wfWaitForSlaves(); |
44 | 44 | $db->commit(); |
45 | 45 | $q = $db->limitResult( "DELETE /* deleteSelfExternals */ FROM externallinks WHERE el_to" |
46 | 46 | . $db->buildLike( $wgServer . '/', $db->anyString() ), $this->mBatchSize ); |
Index: trunk/phase3/maintenance/moveBatch.php |
— | — | @@ -101,7 +101,7 @@ |
102 | 102 | if ( $interval ) { |
103 | 103 | sleep( $interval ); |
104 | 104 | } |
105 | | - wfWaitForSlaves( 5 ); |
| 105 | + wfWaitForSlaves(); |
106 | 106 | } |
107 | 107 | } |
108 | 108 | } |
Index: trunk/phase3/maintenance/populateCategory.php |
— | — | @@ -119,7 +119,7 @@ |
120 | 120 | ++$i; |
121 | 121 | if ( !( $i % self::REPORTING_INTERVAL ) ) { |
122 | 122 | $this->output( "$name\n" ); |
123 | | - wfWaitForSlaves( $maxlag ); |
| 123 | + wfWaitForSlaves(); |
124 | 124 | } |
125 | 125 | usleep( $throttle * 1000 ); |
126 | 126 | } |
Index: trunk/phase3/maintenance/importImages.php |
— | — | @@ -249,8 +249,8 @@ |
250 | 250 | $article = new Article( $title ); |
251 | 251 | echo "\nWaiting for slaves...\n"; |
252 | 252 | // Wait for slaves. |
253 | | - sleep( 2.0 ); |
254 | | - wfWaitForSlaves( 1.0 ); |
| 253 | + sleep( 2.0 ); # Why this sleep? |
| 254 | + wfWaitForSlaves(); |
255 | 255 | |
256 | 256 | echo( "\nSetting image restrictions ... " ); |
257 | 257 | if ( $article->updateRestrictions( $restrictions ) ) |
Index: trunk/phase3/maintenance/importDump.php |
— | — | @@ -154,7 +154,7 @@ |
155 | 155 | $this->progress( "$this->revCount ($revrate revs/sec)" ); |
156 | 156 | } |
157 | 157 | } |
158 | | - wfWaitForSlaves( 5 ); |
| 158 | + wfWaitForSlaves(); |
159 | 159 | // XXX: Don't let deferred jobs array get absurdly large (bug 24375) |
160 | 160 | wfDoUpdates( 'commit' ); |
161 | 161 | } |
Index: trunk/phase3/maintenance/updateSpecialPages.php |
— | — | @@ -58,7 +58,7 @@ |
59 | 59 | } |
60 | 60 | $this->output( sprintf( "completed in %.2fs\n", $seconds ) ); |
61 | 61 | # Wait for the slave to catch up |
62 | | - wfWaitForSlaves( 5 ); |
| 62 | + wfWaitForSlaves(); |
63 | 63 | } |
64 | 64 | |
65 | 65 | // This is needed to initialise $wgQueryPages |
— | — | @@ -130,7 +130,7 @@ |
131 | 131 | $dbw->commit(); |
132 | 132 | } |
133 | 133 | # Wait for the slave to catch up |
134 | | - wfWaitForSlaves( 5 ); |
| 134 | + wfWaitForSlaves(); |
135 | 135 | } else { |
136 | 136 | $this->output( "cheap, skipped\n" ); |
137 | 137 | } |
Index: trunk/phase3/maintenance/deleteBatch.php |
— | — | @@ -104,7 +104,7 @@ |
105 | 105 | if ( $interval ) { |
106 | 106 | sleep( $interval ); |
107 | 107 | } |
108 | | - wfWaitForSlaves( 5 ); |
| 108 | + wfWaitForSlaves(); |
109 | 109 | } |
110 | 110 | } |
111 | 111 | } |
Index: trunk/phase3/maintenance/runJobs.php |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | if ( !$job ) |
74 | 74 | break; |
75 | 75 | |
76 | | - wfWaitForSlaves( 5 ); |
| 76 | + wfWaitForSlaves(); |
77 | 77 | $t = microtime( true ); |
78 | 78 | $offset = $job->id; |
79 | 79 | $status = $job->run(); |
Index: trunk/phase3/maintenance/convertUserOptions.php |
— | — | @@ -46,7 +46,7 @@ |
47 | 47 | $id = $this->convertOptionBatch( $res, $dbw ); |
48 | 48 | $dbw->commit(); |
49 | 49 | |
50 | | - wfWaitForSlaves( 1 ); |
| 50 | + wfWaitForSlaves(); |
51 | 51 | |
52 | 52 | if ( $id ) |
53 | 53 | $this->output( "--Converted to ID $id\n" ); |
Index: trunk/phase3/maintenance/deleteDefaultMessages.php |
— | — | @@ -64,7 +64,7 @@ |
65 | 65 | |
66 | 66 | foreach ( $res as $row ) { |
67 | 67 | if ( function_exists( 'wfWaitForSlaves' ) ) { |
68 | | - wfWaitForSlaves( 5 ); |
| 68 | + wfWaitForSlaves(); |
69 | 69 | } |
70 | 70 | $dbw->ping(); |
71 | 71 | $title = Title::makeTitle( $row->page_namespace, $row->page_title ); |
Index: trunk/phase3/maintenance/migrateUserGroup.php |
— | — | @@ -60,7 +60,7 @@ |
61 | 61 | $dbw->commit(); |
62 | 62 | $blockStart += $this->mBatchSize; |
63 | 63 | $blockEnd += $this->mBatchSize; |
64 | | - wfWaitForSlaves( 5 ); |
| 64 | + wfWaitForSlaves(); |
65 | 65 | } |
66 | 66 | $this->output( "Done! $count user(s) in group '$oldGroup' are now in '$newGroup' instead.\n" ); |
67 | 67 | } |
Index: trunk/phase3/maintenance/populateRevisionLength.php |
— | — | @@ -78,7 +78,7 @@ |
79 | 79 | } |
80 | 80 | $blockStart += $this->mBatchSize; |
81 | 81 | $blockEnd += $this->mBatchSize; |
82 | | - wfWaitForSlaves( 5 ); |
| 82 | + wfWaitForSlaves(); |
83 | 83 | } |
84 | 84 | $logged = $db->insert( 'updatelog', |
85 | 85 | array( 'ul_key' => 'populate rev_len' ), |
Index: trunk/phase3/maintenance/populateParentId.php |
— | — | @@ -98,7 +98,7 @@ |
99 | 99 | } |
100 | 100 | $blockStart += $this->mBatchSize; |
101 | 101 | $blockEnd += $this->mBatchSize; |
102 | | - wfWaitForSlaves( 5 ); |
| 102 | + wfWaitForSlaves(); |
103 | 103 | } |
104 | 104 | $logged = $db->insert( 'updatelog', |
105 | 105 | array( 'ul_key' => 'populate rev_parent_id' ), |
Index: trunk/phase3/maintenance/updateRestrictions.php |
— | — | @@ -96,7 +96,7 @@ |
97 | 97 | } |
98 | 98 | $blockStart += $this->mBatchSize - 1; |
99 | 99 | $blockEnd += $this->mBatchSize - 1; |
100 | | - wfWaitForSlaves( 5 ); |
| 100 | + wfWaitForSlaves(); |
101 | 101 | } |
102 | 102 | $this->output( "...removing dead rows from page_restrictions\n" ); |
103 | 103 | // Kill any broken rows from previous imports |
Index: trunk/phase3/maintenance/upgrade1_5.php |
— | — | @@ -101,7 +101,6 @@ |
102 | 102 | |
103 | 103 | $this->cleanupSwaps = array(); |
104 | 104 | $this->emailAuth = false; # don't preauthenticate emails |
105 | | - $this->maxLag = 10; # if slaves are lagged more than 10 secs, wait |
106 | 105 | $this->step = $this->getOption( 'step', null ); |
107 | 106 | } |
108 | 107 | |
— | — | @@ -316,7 +315,7 @@ |
317 | 316 | */ |
318 | 317 | function insertChunk( &$chunk ) { |
319 | 318 | // Give slaves a chance to catch up |
320 | | - wfWaitForSlaves( $this->maxLag ); |
| 319 | + wfWaitForSlaves(); |
321 | 320 | $this->dbw->insert( $this->chunkTable, $chunk, $this->chunkFunction, $this->chunkOptions ); |
322 | 321 | } |
323 | 322 | |
Index: trunk/phase3/maintenance/populateLogUsertext.php |
— | — | @@ -59,7 +59,7 @@ |
60 | 60 | $db->commit(); |
61 | 61 | $blockStart += $this->mBatchSize; |
62 | 62 | $blockEnd += $this->mBatchSize; |
63 | | - wfWaitForSlaves( 5 ); |
| 63 | + wfWaitForSlaves(); |
64 | 64 | } |
65 | 65 | if ( $db->insert( |
66 | 66 | 'updatelog', |
Index: trunk/phase3/maintenance/populateLogSearch.php |
— | — | @@ -130,7 +130,7 @@ |
131 | 131 | } |
132 | 132 | $blockStart += self::LOG_SEARCH_BATCH_SIZE; |
133 | 133 | $blockEnd += self::LOG_SEARCH_BATCH_SIZE; |
134 | | - wfWaitForSlaves( 5 ); |
| 134 | + wfWaitForSlaves(); |
135 | 135 | } |
136 | 136 | if ( $db->insert( |
137 | 137 | 'updatelog', |
Index: trunk/phase3/maintenance/initEditCount.php |
— | — | @@ -93,7 +93,7 @@ |
94 | 94 | $delta, |
95 | 95 | $rate ) ); |
96 | 96 | |
97 | | - wfWaitForSlaves( 10 ); |
| 97 | + wfWaitForSlaves(); |
98 | 98 | } |
99 | 99 | } else { |
100 | 100 | // Subselect should work on modern MySQLs etc |
Index: trunk/phase3/maintenance/gearman/gearmanWorker.php |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | $interval = 5; |
38 | 38 | $now = time(); |
39 | 39 | if ( $now - $lastSleep >= $interval ) { |
40 | | - wfWaitForSlaves( $interval ); |
| 40 | + wfWaitForSlaves(); |
41 | 41 | $lastSleep = $now; |
42 | 42 | } |
43 | 43 | return false; |
Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -3146,43 +3146,17 @@ |
3147 | 3147 | } |
3148 | 3148 | |
3149 | 3149 | /** |
3150 | | - * Sleep until the worst slave's replication lag is less than or equal to |
3151 | | - * $maxLag, in seconds. Use this when updating very large numbers of rows, as |
| 3150 | + * Modern version of wfWaitForSlaves(). Instead of looking at replication lag |
| 3151 | + * and waiting for it to go down, this waits for the slaves to catch up to the |
| 3152 | + * master position. Use this when updating very large numbers of rows, as |
3152 | 3153 | * in maintenance scripts, to avoid causing too much lag. Of course, this is |
3153 | 3154 | * a no-op if there are no slaves. |
3154 | | - * |
3155 | | - * Every time the function has to wait for a slave, it will print a message to |
3156 | | - * that effect (and then sleep for a little while), so it's probably not best |
3157 | | - * to use this outside maintenance scripts in its present form. |
3158 | | - * |
3159 | | - * @param $maxLag Integer |
| 3155 | + * |
| 3156 | + * @param $maxLag Integer (deprecated) |
3160 | 3157 | * @param $wiki mixed Wiki identifier accepted by wfGetLB |
3161 | 3158 | * @return null |
3162 | 3159 | */ |
3163 | | -function wfWaitForSlaves( $maxLag, $wiki = false ) { |
3164 | | - if( $maxLag ) { |
3165 | | - $lb = wfGetLB( $wiki ); |
3166 | | - list( $host, $lag ) = $lb->getMaxLag( $wiki ); |
3167 | | - while( $lag > $maxLag ) { |
3168 | | - wfSuppressWarnings(); |
3169 | | - $name = gethostbyaddr( $host ); |
3170 | | - wfRestoreWarnings(); |
3171 | | - if( $name !== false ) { |
3172 | | - $host = $name; |
3173 | | - } |
3174 | | - print "Waiting for $host (lagged $lag seconds)...\n"; |
3175 | | - sleep( $maxLag ); |
3176 | | - list( $host, $lag ) = $lb->getMaxLag(); |
3177 | | - } |
3178 | | - } |
3179 | | -} |
3180 | | - |
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() { |
| 3160 | +function wfWaitForSlaves( $maxLag = false, $wiki = false ) { |
3187 | 3161 | $lb = wfGetLB(); |
3188 | 3162 | // bug 27975 - Don't try to wait for slaves if there are none |
3189 | 3163 | // Prevents permission error when getting master position |
Index: trunk/phase3/includes/installer/MysqlUpdater.php |
— | — | @@ -652,7 +652,7 @@ |
653 | 653 | foreach ( $res as $row ) { |
654 | 654 | $count = ( $count + 1 ) % 100; |
655 | 655 | if ( $count == 0 ) { |
656 | | - wfWaitForSlaves( 10 ); |
| 656 | + wfWaitForSlaves(); |
657 | 657 | } |
658 | 658 | $this->db->insert( 'templatelinks', |
659 | 659 | array( |
Index: trunk/phase3/includes/job/RefreshLinksJob.php |
— | — | @@ -119,7 +119,7 @@ |
120 | 120 | $update = new LinksUpdate( $title, $parserOutput, false ); |
121 | 121 | $update->doUpdate(); |
122 | 122 | wfProfileOut( __METHOD__.'-update' ); |
123 | | - wfWaitForSlaves( 5 ); |
| 123 | + wfWaitForSlaves(); |
124 | 124 | } |
125 | 125 | wfProfileOut( __METHOD__ ); |
126 | 126 | |