From b83499b1ff60be4760e87b979cde9e9ff9418d19 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sat, 22 Oct 2005 17:19:17 +0000 Subject: [PATCH] --endid option, minor tweaks --- maintenance/storage/compressOld.inc | 16 +++++++++++++--- maintenance/storage/compressOld.php | 15 ++++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/maintenance/storage/compressOld.inc b/maintenance/storage/compressOld.inc index 36dc326579..c61e9e0b47 100644 --- a/maintenance/storage/compressOld.inc +++ b/maintenance/storage/compressOld.inc @@ -71,7 +71,8 @@ define( 'LS_INDIVIDUAL', 0 ); define( 'LS_CHUNKED', 1 ); /** @todo document */ -function compressWithConcat( $startId, $maxChunkSize, $maxChunkFactor, $factorThreshold, $beginDate, $endDate, $extdb="" ) +function compressWithConcat( $startId, $maxChunkSize, $maxChunkFactor, $factorThreshold, $beginDate, + $endDate, $extdb="", $maxPageId = false ) { $fname = 'compressWithConcat'; $loadStyle = LS_CHUNKED; @@ -79,8 +80,16 @@ function compressWithConcat( $startId, $maxChunkSize, $maxChunkFactor, $factorTh $dbr =& wfGetDB( DB_SLAVE ); $dbw =& wfGetDB( DB_MASTER ); + # Set up external storage + if ( $extdb != '' ) { + $storeObj = new ExternalStoreDB; + } + # Get all articles by page_id - $maxPageId = $dbr->selectField( 'page', 'max(page_id)', '', $fname ); + if ( !$maxPageId ) { + $maxPageId = $dbr->selectField( 'page', 'max(page_id)', '', $fname ); + } + print "Starting from $startId of $maxPageId\n"; $pageConds = array(); /* @@ -124,6 +133,8 @@ function compressWithConcat( $startId, $maxChunkSize, $maxChunkFactor, $factorTh $totalMatchingRevisions = 0; $masterPos = false; for ( $pageId = $startId; $pageId <= $maxPageId; $pageId++ ) { + wfWaitForSlaves( 10 ); + $pageRes = $dbr->select( 'page', array('page_id', 'page_namespace', 'page_title'), $pageConds + array('page_id' => $pageId), $fname ); if ( $dbr->numRows( $pageRes ) == 0 ) { @@ -215,7 +226,6 @@ function compressWithConcat( $startId, $maxChunkSize, $maxChunkFactor, $factorTh if ( $usedChunk ) { if ( $extdb != "" ) { # Move blob objects to External Storage - $storeObj = new ExternalStoreDB; $stored = $storeObj->store( $extdb, serialize( $chunk )); if ($stored === false) { print "Unable to store object\n"; diff --git a/maintenance/storage/compressOld.php b/maintenance/storage/compressOld.php index 35d8c82946..b9ce924b92 100644 --- a/maintenance/storage/compressOld.php +++ b/maintenance/storage/compressOld.php @@ -31,7 +31,7 @@ * */ -$optionsWithArgs = array( 't', 'c', 's', 'f', 'h', 'extdb' ); +$optionsWithArgs = array( 't', 'c', 's', 'f', 'h', 'extdb', 'endid' ); require_once( "../commandLine.inc" ); require_once( "compressOld.inc" ); @@ -50,6 +50,7 @@ $defaults = array( 'b' => '', 'e' => '', 'extdb' => '', + 'endid' => false, ); $options = $options + $defaults; @@ -58,16 +59,16 @@ if ( $options['t'] != 'concat' && $options['t'] != 'gzip' ) { print "Type \"{$options['t']}\" not supported\n"; } -print "Depending on the size of your database this may take a while!\n"; -print "If you abort the script while it's running it shouldn't harm anything,\n"; -print "but if you haven't backed up your data, you SHOULD abort now!\n\n"; -print "Press control-c to abort first (will proceed automatically in 5 seconds)\n"; -#sleep(5); +if ( $options['extdb'] != '' ) { + print "Compressing database $wgDBname to external cluster {$options['extdb']}\n" . str_repeat('-', 76) . "\n\n"; +} else { + print "Compressing database $wgDBname\n" . str_repeat('-', 76) . "\n\n"; +} $success = true; if ( $options['t'] == 'concat' ) { $success = compressWithConcat( $options['s'], $options['c'], $options['f'], $options['h'], $options['b'], - $options['e'], $options['extdb'] ); + $options['e'], $options['extdb'], $options['endid'] ); } else { compressOldPages( $options['s'], $options['extdb'] ); } -- 2.20.1