/**
* Translation using MediaWiki: namespace.
- * This will increase load times by 25-60% unless memcached is installed.
* Interface messages will be loaded from the database.
*/
$wgUseDatabaseMessages = true;
$wgExtraSubtitle = '';
$wgSiteSupportPage = ''; # A page where you users can receive donations
+/**
+ * Set this to a string to put the wiki into read-only mode. The text will be
+ * used as an explanation to users.
+ *
+ * This prevents most write operations via the web interface. Cache updates may
+ * still be possible. To prevent database writes completely, use the read_only
+ * option in MySQL.
+ */
+$wgReadOnly = null;
+
/***
* If this lock file exists, the wiki will be forced into read-only mode.
* Its contents will be shown to users as part of the read-only warning
$wgReadOnlyFile = false; ///< defaults to "{$wgUploadDirectory}/lock_yBgMBwiR";
/**
+ * Filename for debug logging.
* The debug log file should be not be publicly accessible if it is used, as it
- * may contain private data. */
+ * may contain private data.
+ */
$wgDebugLogFile = '';
+/**
+ * Prefix for debug log lines
+ */
+$wgDebugLogPrefix = '';
+
+/**
+ * If true, instead of redirecting, show a page with a link to the redirect
+ * destination. This allows for the inspection of PHP error messages, and easy
+ * resubmission of form data. For developer use only.
+ */
$wgDebugRedirects = false;
-$wgDebugRawPage = false; # Avoid overlapping debug entries by leaving out CSS
+/**
+ * If true, log debugging data from action=raw.
+ * This is normally false to avoid overlapping debug entries due to gen=css and
+ * gen=js requests.
+ */
+$wgDebugRawPage = false;
+
+/**
+ * Send debug data to an HTML comment in the output.
+ *
+ * This may occasionally be useful when supporting a non-technical end-user. It's
+ * more secure than exposing the debug log file to the web, since the output only
+ * contains private data for the current user. But it's not ideal for development
+ * use since data is lost on fatal errors and redirects.
+ */
$wgDebugComments = false;
-$wgReadOnly = null;
+
+/** Does nothing. Obsolete? */
$wgLogQueries = false;
/**
* same options.
*
* This can provide a significant speedup for medium to large pages,
- * so you probably want to keep it on.
+ * so you probably want to keep it on. Extensions that conflict with the
+ * parser cache should disable the cache on a per-page basis instead.
*/
$wgEnableParserCache = true;
require( dirname( __FILE__ ) .'/../commandLine.inc' );
if ( count( $args ) < 1 ) {
- echo "Usage: php recompressTracked.php <cluster> [... <cluster>...]\n";
- echo "Moves blobs indexed by trackBlobs.php to a specified list of destination
-clusters, and recompresses them in the process. Restartable.\n";
+ echo "Usage: php recompressTracked.php [options] <cluster> [... <cluster>...]
+Moves blobs indexed by trackBlobs.php to a specified list of destination clusters, and recompresses them in the process. Restartable.
+
+Options:
+ --procs <procs> Set the number of child processes (default 8)
+ --copy-only Copy only, do not update the text table. Restart without this option to complete.
+";
exit( 1 );
}
var $batchSize = 1000;
var $reportingInterval = 10;
var $numProcs = 8;
+ var $useDiff, $pageBlobClass, $orphanBlobClass;
var $slavePipes, $slaveProcs, $prevSlaveId;
- var $blobClass = 'DiffHistoryBlob';
var $copyOnly = false;
var $isChild = false;
var $slaveId = false;
var $store;
- static $optionsWithArgs = array( 'procs', 'class' );
+ static $optionsWithArgs = array( 'procs', 'slave-id' );
static $cmdLineOptionMap = array(
'procs' => 'numProcs',
- 'class' => 'blobClass',
'copy-only' => 'copyOnly',
'child' => 'isChild',
'slave-id' => 'slaveId',
$this->$name = $value;
}
$this->store = new ExternalStoreDB;
+ if ( !$this->isChild ) {
+ $GLOBALS['wgDebugLogPrefix'] = "RCT M: ";
+ } elseif ( $this->slaveId !== false ) {
+ $GLOBALS['wgDebugLogPrefix'] = "RCT {$this->slaveId}: ";
+ }
+ $this->useDiff = function_exists( 'xdiff_string_bdiff' );
+ $this->pageBlobClass = $this->useDiff ? 'DiffHistoryBlob' : 'ConcatenatedGzipHistoryBlob';
+ $this->orphanBlobClass = 'ConcatenatedGzipHistoryBlob';
}
function debug( $msg ) {
- if ( $this->slaveId !== false ) {
- $msg = "{$this->slaveId}: $msg";
- }
- $msg .= "\n";
- wfDebug( $msg );
+ wfDebug( "$msg\n" );
}
/**
array( 'file', '/dev/stderr', 'w' )
);
wfSuppressWarnings();
- $proc = proc_open( $cmd, $spec, $pipes );
+ $proc = proc_open( "$cmd --slave-id $i", $spec, $pipes );
wfRestoreWarnings();
if ( !$proc ) {
echo "Error opening slave process\n";
* Main entry point for worker processes
*/
function executeChild() {
+ $this->debug( 'starting' );
$this->syncDBs();
while ( !feof( STDIN ) ) {
if ( $line == '' ) {
continue;
}
+ $this->debug( $line );
$args = explode( ' ', $line );
$cmd = array_shift( $args );
switch ( $cmd ) {
* Move tracked text in a given page
*/
function doPage( $pageId ) {
+ $title = Title::newFromId( $pageId );
+ if ( $title ) {
+ $titleText = $title->getPrefixedText();
+ } else {
+ $titleText = '[deleted]';
+ }
$dbr = wfGetDB( DB_SLAVE );
// Finish any incomplete transactions
if ( !$this->copyOnly ) {
- $this->finishIncompleteMoves();
+ $this->finishIncompleteMoves( array( 'bt_page' => $pageId ) );
}
$startId = 0;
- $trx = new CgzCopyTransaction( $this );
+ $trx = new CgzCopyTransaction( $this, $this->pageBlobClass );
while ( true ) {
$res = $dbr->select(
'bt_page' => $pageId,
'bt_text_id > ' . $dbr->addQuotes( $startId ),
'bt_moved' => 0,
- 'bt_new_url' => '',
+ 'bt_new_url IS NULL',
'bt_text_id=old_id',
),
__METHOD__,
// Queue it
if ( !$trx->addItem( $text, $row->bt_text_id ) ) {
+ $this->debug( "$titleText: committing blob with " . $trx->getSize() . " items" );
$trx->commit();
- $trx = new CgzCopyTransaction( $this );
+ $trx = new CgzCopyTransaction( $this, $this->pageBlobClass );
}
}
$startId = $row->bt_text_id;
}
+
+ $this->debug( "$titleText: committing blob with " . $trx->getSize() . " items" );
$trx->commit();
}
* This function completes any moves that only have done bt_new_url. This
* can happen when the script is interrupted, or when --copy-only is used.
*/
- function finishIncompleteMoves() {
+ function finishIncompleteMoves( $conds ) {
$dbr = wfGetDB( DB_SLAVE );
$startId = 0;
+ $conds = array_merge( $conds, array(
+ 'bt_moved' => 0,
+ 'bt_new_url IS NOT NULL'
+ ));
while ( true ) {
$res = $dbr->select( 'blob_tracking',
'*',
- array(
- 'bt_text_id > ' . $dbr->addQuotes( $startId ),
- 'bt_moved' => 0,
- "bt_new_url <> ''",
- ),
+ array_merge( $conds, array( 'bt_text_id > ' . $dbr->addQuotes( $startId ) ) ),
__METHOD__,
array(
'ORDER BY' => 'bt_text_id',
if ( !$res->numRows() ) {
break;
}
+ $this->debug( 'Incomplete: ' . $row->numRows() . ' rows' );
foreach ( $res as $row ) {
$this->moveTextRow( $row->bt_text_id, $row->bt_new_url );
}
* Move an orphan text_id to the new cluster
*/
function doOrphanList( $textIds ) {
- $trx = new CgzCopyTransaction( $this );
+ // Finish incomplete moves
+ $this->finishIncompleteMoves( array( 'bt_text_id' => $textIds ) );
+
+ $trx = new CgzCopyTransaction( $this, $this->orphanBlobClass );
foreach ( $textIds as $textId ) {
$row = wfGetDB( DB_SLAVE )->selectRow( 'text', array( 'old_text', 'old_flags' ),
array( 'old_id' => $textId ), __METHOD__ );
}
if ( !$trx->addItem( $text, $textId ) ) {
+ $this->debug( "[orphan]: committing blob with " . $trx->getSize() . " rows" );
$trx->commit();
- $trx = new CgzCopyTransaction( $this );
+ $trx = new CgzCopyTransaction( $this, $this->orphanBlobClass );
}
}
+ $this->debug( "[orphan]: committing blob with " . $trx->getSize() . " rows" );
+ $trx->commit();
}
}
* Class to represent a recompression operation for a single CGZ blob
*/
class CgzCopyTransaction {
+ var $parent;
var $blobClass;
var $cgz;
var $referrers;
/**
* Create a transaction from a RecompressTracked object
*/
- function __construct( $parent ) {
- $this->blobClass = $parent->blobClass;
+ function __construct( $parent, $blobClass ) {
+ $this->blobClass = $blobClass;
$this->cgz = false;
$this->texts = array();
+ $this->parent = $parent;
}
/**
return $this->cgz->isHappy();
}
+ function getSize() {
+ return count( $this->texts );
+ }
+
/**
* Recompress text after some aberrant modification
*/
// We do a locking read to prevent closer-run race conditions.
$dbw = wfGetDB( DB_MASTER );
$dbw->begin();
+ $res = $dbw->select( 'blob_tracking',
+ array( 'bt_text_id', 'bt_moved' ),
+ array( 'bt_text_id' => array_keys( $this->referrers ) ),
+ __METHOD__, array( 'FOR UPDATE' ) );
$dirty = false;
- foreach ( $this->referrers as $textId => $hash ) {
- $moved = $dbw->selectField( 'blob_tracking', 'bt_moved',
- array( 'bt_text_id' => $textId ),
- __METHOD__,
- array( 'FOR UPDATE' )
- );
- if ( !$moved ) {
+ foreach ( $res as $row ) {
+ if ( $row->bt_moved ) {
# This row has already been moved, remove it
- unset( $this->texts[$textId] );
+ $this->parent->debug( "TRX: conflict detected in old_id={$row->bt_text_id}" );
+ unset( $this->texts[$row->bt_text_id] );
$dirty = true;
}
}
// All have been moved already
if ( $originalCount > 1 ) {
// This is suspcious, make noise
- echo "Warning: concurrent operation detected, are there two conflicting\n" .
+ echo "Warning: concurrent operation detected, are there two conflicting " .
"processes running, doing the same job?\n";
}
return;
}
}
}
-
- function signalHandler() {
- $this->signalled = true;
- }
}