Index: trunk/phase3/maintenance/storage/checkStorage.php |
— | — | @@ -17,31 +17,8 @@ |
18 | 18 |
|
19 | 19 | //----------------------------------------------------------------------------------
|
20 | 20 |
|
21 | | -function checkError( $msg, $ids ) {
|
22 | | - global $oldIdMap;
|
23 | | - if ( is_array( $ids ) && count( $ids ) == 1 ) {
|
24 | | - $ids = reset( $ids );
|
25 | | - }
|
26 | | - if ( is_array( $ids ) ) {
|
27 | | - $revIds = array();
|
28 | | - foreach ( $ids as $id ) {
|
29 | | - $revIds = array_merge( $revIds, array_keys( $oldIdMap, $id ) );
|
30 | | - }
|
31 | | - print "$msg in text rows " . implode( ', ', $ids ) .
|
32 | | - ", revisions " . implode( ', ', $revIds ) . "\n";
|
33 | | - } else {
|
34 | | - $id = $ids;
|
35 | | - $revIds = array_keys( $oldIdMap, $id );
|
36 | | - if ( count( $revIds ) == 1 ) {
|
37 | | - print "$msg in old_id $id, rev_id {$revIds[0]}\n";
|
38 | | - } else {
|
39 | | - print "$msg in old_id $id, revisions " . implode( ', ', $revIds ) . "\n";
|
40 | | - }
|
41 | | - }
|
42 | | -}
|
43 | | -
|
44 | 21 | function checkStorage() {
|
45 | | - global $oldIdMap;
|
| 22 | + global $oldIdMap, $brokenRevisions;
|
46 | 23 |
|
47 | 24 | $fname = 'checkStorage';
|
48 | 25 | $dbr =& wfGetDB( DB_SLAVE );
|
— | — | @@ -51,10 +28,11 @@ |
52 | 29 | $objectStats = array();
|
53 | 30 | $knownFlags = array( 'external', 'gzip', 'object', 'utf-8' );
|
54 | 31 | $dbStore = null;
|
| 32 | + $brokenRevisions = array();
|
55 | 33 |
|
56 | 34 | for ( $chunkStart = 1 ; $chunkStart < $maxRevId; $chunkStart += $chunkSize ) {
|
57 | 35 | $chunkEnd = $chunkStart + $chunkSize - 1;
|
58 | | - //print "$chunkStart to $chunkEnd of $maxRevId\n";
|
| 36 | + //print "$chunkStart of $maxRevId\n";
|
59 | 37 |
|
60 | 38 | // Fetch revision rows
|
61 | 39 | $oldIdMap = array();
|
— | — | @@ -65,6 +43,10 @@ |
66 | 44 | }
|
67 | 45 | $dbr->freeResult( $res );
|
68 | 46 |
|
| 47 | + if ( !count( $oldIdMap ) ) {
|
| 48 | + continue;
|
| 49 | + }
|
| 50 | +
|
69 | 51 | // Fetch old_flags
|
70 | 52 | $missingTextRows = array_flip( $oldIdMap );
|
71 | 53 | $externalRevs = array();
|
— | — | @@ -100,7 +82,6 @@ |
101 | 83 |
|
102 | 84 | // Check for unrecognised flags
|
103 | 85 | if ( count( array_diff( $flagArray, $knownFlags ) ) ) {
|
104 | | - print_r( array_diff( $flagArray, $knownFlags ) );
|
105 | 86 | checkError( "Warning: invalid flags field \"$flags\"", $id );
|
106 | 87 | }
|
107 | 88 | }
|
— | — | @@ -182,7 +163,7 @@ |
183 | 164 | continue;
|
184 | 165 | }
|
185 | 166 |
|
186 | | - $className = $matches[2];
|
| 167 | + $className = strtolower( $matches[2] );
|
187 | 168 | if ( strlen( $className ) != $matches[1] ) {
|
188 | 169 | checkError( "Error: invalid object header, wrong class name length", $oldId );
|
189 | 170 | continue;
|
— | — | @@ -247,7 +228,7 @@ |
248 | 229 | checkError( "Error: invalid flags \"{$row->old_flags}\" on concat bulk row {$row->old_id}",
|
249 | 230 | $concatBlobs[$row->old_id] );
|
250 | 231 | }
|
251 | | - } elseif ( substr( $row->header, 0, strlen( CONCAT_HEADER ) ) != CONCAT_HEADER ) {
|
| 232 | + } elseif ( strcasecmp( substr( $row->header, 0, strlen( CONCAT_HEADER ) ), CONCAT_HEADER ) ) {
|
252 | 233 | checkError( "Error: Incorrect object header for concat bulk row {$row->old_id}",
|
253 | 234 | $concatBlobs[$row->old_id] );
|
254 | 235 | } # else good
|
— | — | @@ -264,7 +245,9 @@ |
265 | 246 | // next chunk
|
266 | 247 | }
|
267 | 248 |
|
268 | | - print "\n\nFlag statistics:\n";
|
| 249 | + print "\n\n" . count( $brokenRevisions ) . " broken revisions\n";
|
| 250 | +
|
| 251 | + print "\nFlag statistics:\n";
|
269 | 252 | $total = array_sum( $flagStats );
|
270 | 253 | foreach ( $flagStats as $flag => $count ) {
|
271 | 254 | printf( "%-30s %10d %5.2f%%\n", $flag, $count, $count / $total * 100 );
|
— | — | @@ -277,6 +260,30 @@ |
278 | 261 | }
|
279 | 262 |
|
280 | 263 |
|
| 264 | +function checkError( $msg, $ids ) {
|
| 265 | + global $oldIdMap, $brokenRevisions;
|
| 266 | + if ( is_array( $ids ) && count( $ids ) == 1 ) {
|
| 267 | + $ids = reset( $ids );
|
| 268 | + }
|
| 269 | + if ( is_array( $ids ) ) {
|
| 270 | + $revIds = array();
|
| 271 | + foreach ( $ids as $id ) {
|
| 272 | + $revIds = array_merge( $revIds, array_keys( $oldIdMap, $id ) );
|
| 273 | + }
|
| 274 | + print "$msg in text rows " . implode( ', ', $ids ) .
|
| 275 | + ", revisions " . implode( ', ', $revIds ) . "\n";
|
| 276 | + } else {
|
| 277 | + $id = $ids;
|
| 278 | + $revIds = array_keys( $oldIdMap, $id );
|
| 279 | + if ( count( $revIds ) == 1 ) {
|
| 280 | + print "$msg in old_id $id, rev_id {$revIds[0]}\n";
|
| 281 | + } else {
|
| 282 | + print "$msg in old_id $id, revisions " . implode( ', ', $revIds ) . "\n";
|
| 283 | + }
|
| 284 | + }
|
| 285 | + $brokenRevisions = $brokenRevisions + array_flip( $revIds );
|
| 286 | +}
|
| 287 | +
|
281 | 288 | function checkExternalConcatBlobs( $externalConcatBlobs ) {
|
282 | 289 | static $dbStore = null;
|
283 | 290 | $fname = 'checkExternalConcatBlobs';
|
— | — | @@ -297,10 +304,10 @@ |
298 | 305 | array( 'blob_id', "LEFT(blob_text, $headerLength) AS header" ),
|
299 | 306 | array( 'blob_id IN( ' . implode( ',', $blobIds ) . ')' ), $fname );
|
300 | 307 | while ( $row = $extDb->fetchObject( $res ) ) {
|
301 | | - if ( $row->header != CONCAT_HEADER ) {
|
302 | | - checkError( "Error: invalid header on target of two-part ES URL",
|
303 | | - $oldIds[$row->blob_id] );
|
304 | | - }
|
| 308 | + if ( strcasecmp( $row->header, CONCAT_HEADER ) ) {
|
| 309 | + checkError( "Error: invalid header on target $cluster/{$row->blob_id} of two-part ES URL",
|
| 310 | + $oldIds[$row->blob_id] );
|
| 311 | + }
|
305 | 312 | unset( $oldIds[$row->blob_id] );
|
306 | 313 |
|
307 | 314 | }
|
— | — | @@ -308,7 +315,7 @@ |
309 | 316 |
|
310 | 317 | // Print errors for missing blobs rows
|
311 | 318 | foreach ( $oldIds as $blobId => $oldIds ) {
|
312 | | - checkError( "Error: missing target $blobId for two-part ES URL", $oldIds );
|
| 319 | + checkError( "Error: missing target $cluster/$blobId for two-part ES URL", $oldIds );
|
313 | 320 | }
|
314 | 321 | }
|
315 | 322 | }
|