r86398 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86397‎ | r86398 | r86399 >
Date:14:52, 19 April 2011
Author:catrope
Status:ok (Comments)
Tags:
Comment:
Put the code for waiting for slave lag the new-and-improved way (using master position) in wfWaitForSlaves_masterPos(). I guess I should deprecate or re-do wfWaitForSlaves() and update callers, but I'm lazy
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/maintenance/runBatchedQuery.php (modified) (history)

Diff [purge]

Index: trunk/phase3/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: trunk/phase3/includes/GlobalFunctions.php
@@ -3178,6 +3178,22 @@
31793179 }
31803180
31813181 /**
 3182+ * Modern version of wfWaitForSlaves(). Instead of looking at replication lag
 3183+ * and waiting for it to go down, this waits for the slaves to catch up to the
 3184+ * master position. This is much better for lag control than wfWaitForSlaves()
 3185+ */
 3186+function wfWaitForSlaves_masterPos() {
 3187+ $lb = wfGetLB();
 3188+ // bug 27975 - Don't try to wait for slaves if there are none
 3189+ // Prevents permission error when getting master position
 3190+ if ( $lb->getServerCount() > 1 ) {
 3191+ $dbw = $lb->getConnection( DB_MASTER );
 3192+ $pos = $dbw->getMasterPos();
 3193+ $lb->waitForAll( $pos );
 3194+ }
 3195+}
 3196+
 3197+/**
31823198 * Used to be used for outputting text in the installer/updater
31833199 * @deprecated Warnings in 1.19, removal in 1.20
31843200 */

Sign-offs

UserFlagDate
Hasharinspected20:41, 7 June 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r863991.17wmf1: MFT r86398 so I can use runBatchedQuery.php on the cluster with pro...catrope14:59, 19 April 2011
r86447Merge r86398 into the old wfWaitForSlaves. Update core calls....platonides00:12, 20 April 2011

Comments

#Comment by Voice of All (talk | contribs)   17:22, 19 April 2011

That function name drives me a little crazy :)

#Comment by Catrope (talk | contribs)   18:40, 19 April 2011

{{sofixit}} ;)

Status & tagging log