X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FupdateCollation.php;h=6b10498c6bd23a46d93e3c391f42ce50a4bca568;hb=6c9a2923fe1ee3a65cb027be5e781772f2b12fbd;hp=6d9a6160770d3911960c4af090eb391ef17bea4d;hpb=32e56eefaa1d9c0a832f9e32db4f9bdaad28f02e;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/updateCollation.php b/maintenance/updateCollation.php index 6d9a616077..84fc2d208e 100644 --- a/maintenance/updateCollation.php +++ b/maintenance/updateCollation.php @@ -26,6 +26,8 @@ require_once __DIR__ . '/Maintenance.php'; +use Wikimedia\Rdbms\IDatabase; + /** * Maintenance script that will find all rows in the categorylinks table * whose collation is out-of-date. @@ -34,7 +36,7 @@ require_once __DIR__ . '/Maintenance.php'; */ class UpdateCollation extends Maintenance { const BATCH_SIZE = 100; // Number of rows to process in one batch - const SYNC_INTERVAL = 20; // Wait for slaves after this many batches + const SYNC_INTERVAL = 5; // Wait for replica DBs after this many batches public $sizeHistogram = []; @@ -70,6 +72,7 @@ TEXT global $wgCategoryCollation; $dbw = $this->getDB( DB_MASTER ); + $dbr = $this->getDB( DB_REPLICA ); $force = $this->getOption( 'force' ); $dryRun = $this->getOption( 'dry-run' ); $verboseStats = $this->getOption( 'verbose-stats' ); @@ -97,9 +100,10 @@ TEXT $options = [ 'LIMIT' => self::BATCH_SIZE, 'ORDER BY' => $orderBy, + 'STRAIGHT_JOIN' // per T58041 ]; - if ( $force || $dryRun ) { + if ( $force ) { $collationConds = []; } else { if ( $this->hasOption( 'previous-collation' ) ) { @@ -110,7 +114,7 @@ TEXT ]; } - $count = $dbw->estimateRowCount( + $count = $dbr->estimateRowCount( 'categorylinks', '*', $collationConds, @@ -118,7 +122,7 @@ TEXT ); // Improve estimate if feasible if ( $count < 1000000 ) { - $count = $dbw->selectField( + $count = $dbr->selectField( 'categorylinks', 'COUNT(*)', $collationConds, @@ -130,7 +134,12 @@ TEXT return; } - $this->output( "Fixing collation for $count rows.\n" ); + if ( $dryRun ) { + $this->output( "$count rows would be updated.\n" ); + } else { + $this->output( "Fixing collation for $count rows.\n" ); + } + wfWaitForSlaves(); } $count = 0; $batchCount = 0; @@ -217,7 +226,7 @@ TEXT $this->output( "$count done.\n" ); if ( !$dryRun && ++$batchCount % self::SYNC_INTERVAL == 0 ) { - $this->output( "Waiting for slaves ... " ); + $this->output( "Waiting for replica DBs ... " ); wfWaitForSlaves(); $this->output( "done\n" ); } @@ -235,7 +244,7 @@ TEXT * Return an SQL expression selecting rows which sort above the given row, * assuming an ordering of cl_collation, cl_to, cl_type, cl_from * @param stdClass $row - * @param DatabaseBase $dbw + * @param IDatabase $dbw * @return string */ function getBatchCondition( $row, $dbw ) {