r86399 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86398‎ | r86399 | r86400 >
Date:14:59, 19 April 2011
Author:catrope
Status:ok
Tags:
Comment:
1.17wmf1: MFT r86398 so I can use runBatchedQuery.php on the cluster with proper wait-for-slave behavior
Modified paths:
  • /branches/wmf/1.17wmf1/includes/GlobalFunctions.php (modified) (history)
  • /branches/wmf/1.17wmf1/maintenance/runBatchedQuery.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/maintenance/runBatchedQuery.php
@@ -29,7 +29,6 @@
3030 parent::__construct();
3131 $this->mDescription = "Run a query repeatedly until it affects 0 rows, and wait for slaves in between.\n" .
3232 "NOTE: You need to set a LIMIT clause yourself.";
33 - $this->addOption( 'wait', "Wait for replication lag to go down to this value. Default: 5", false, true );
3433 }
3534
3635 public function execute() {
@@ -46,7 +45,7 @@
4746 $dbw->query( $query, __METHOD__ );
4847 $affected = $dbw->affectedRows();
4948 $this->output( "$affected rows\n" );
50 - wfWaitForSlaves( $wait );
 49+ wfWaitForSlaves_masterPos();
5150 } while ( $affected > 0 );
5251 }
5352
Index: branches/wmf/1.17wmf1/includes/GlobalFunctions.php
@@ -3425,6 +3425,22 @@
34263426 }
34273427
34283428 /**
 3429+ * Modern version of wfWaitForSlaves(). Instead of looking at replication lag
 3430+ * and waiting for it to go down, this waits for the slaves to catch up to the
 3431+ * master position. This is much better for lag control than wfWaitForSlaves()
 3432+ */
 3433+function wfWaitForSlaves_masterPos() {
 3434+ $lb = wfGetLB();
 3435+ // bug 27975 - Don't try to wait for slaves if there are none
 3436+ // Prevents permission error when getting master position
 3437+ if ( $lb->getServerCount() > 1 ) {
 3438+ $dbw = $lb->getConnection( DB_MASTER );
 3439+ $pos = $dbw->getMasterPos();
 3440+ $lb->waitForAll( $pos );
 3441+ }
 3442+}
 3443+
 3444+/**
34293445 * Used to be used for outputting text in the installer/updater
34303446 * @deprecated Warnings in 1.19, removal in 1.20
34313447 */
Property changes on: branches/wmf/1.17wmf1/includes/GlobalFunctions.php
___________________________________________________________________
Modified: svn:mergeinfo
34323448 Merged /trunk/phase3/includes/GlobalFunctions.php:r86398

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r86398Put the code for waiting for slave lag the new-and-improved way (using master...catrope14:52, 19 April 2011

Status & tagging log